Can anyone figure out why, in sub test(), iRow is always equal to 1 when a blank sheet is being used? (Cells(iRow,1).value = i always puts the data in A1. My intention is that as data is added to a row, getRowCount() should return an incremented number to show a new item has been added. Each datum should have it's own consecutive cell in column A. Code follows:
Public Function getRowCount() As Integer
Dim tempRows As Integer
tempRows = Worksheets("sheet1").UsedRange.Rows.Count
getRowCount = tempRows
End Function
Sub test()
Dim i As Integer, iRow As Integer
For i = 1 To 10
iRow = getRowCount()
Cells(iRow, 1).Value = i
Next
End Sub
Public Function getRowCount() As Integer
Dim tempRows As Integer
tempRows = Worksheets("sheet1").UsedRange.Rows.Count
getRowCount = tempRows
End Function
Sub test()
Dim i As Integer, iRow As Integer
For i = 1 To 10
iRow = getRowCount()
Cells(iRow, 1).Value = i
Next
End Sub