Search code examples
excelexcel-2013vba

Excel VBA .End(xlUp).Offset(1, 0).Row


Making a userform to add data to a database in VBA. What i'm wanting to do is pretty simple; to select the last filled row, and skip to the next empty cell in the row below.

Screenshot added with the problem highlighted.

enter image description here

Question is quite simple, what am I doing wrong, and how would it be fixed?


Solution

  • .End(... has nothing to reference to. If you wanted to add a linebreak, do so by writing:

    Irow = ws.Cells(Rows.Count, 1) _
    .End(xlUp).Offset(1,0).Row
    

    Watch the _ with a space before it at the end of the first line. This will connect the two lines, forming one valid statement.

    Alternatively, just write the two lines as one:

    Irow = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1,0).Row