Reputation: 121
I have a form which adds input information from VBA UserForm into dedicated cells, e.g. First Name, Last Name, I'm using iRow = ws.Cells(Rows.Count, 2).End(xlUp).Offset(1, 0).Row
to find an empty row, and to add information in a specific column of the row. By default, the information is printed on B1, is it possible to change it to G7 for example?
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Sheet1")
ws.Cells(iRow, 2).Value = Me.txt_firstname
ws.Cells(iRow, 3).Value = Me.txt_lastname
Upvotes: 0
Views: 1250
Reputation: 2666
Change your row count to this:
iRow = ws.Cells(Rows.Count, 7).End(xlUp).Offset(1, 0).Row
If iRow<7 then
iRow =7
End if
ws.Cells(iRow, 7).Value = Me.txt_firstname
This will change your cell count to at least row 7, if the first cell is later than that, it will add it to next empty row after that.
Upvotes: 2