Problem with offsetting one row down

R

Raj

Row 1 of the sheet has column headers. Row 2 has data and is hidden.
The following code is used to offset one row down from the last filled
row in the column 1

nextrow = ws.Cells(rows.count,1).end(xlup).offset(1,0).row

nextrow shows 2 instead of 3 ie. it seems to be offsetting one row
down from the visible row ie row 1.

How can I ensure that the nextrow is 3 and not 2 in the above
example.

Thanks in advance for the help.

Regards,
Raj
 
P

Per Jessen

Insert the line below after the line mentioned:

If NextRow=2 then NextRow=3

Regards,
Per
 
D

Don Guillett

Sub lastcell()
nextrow = .Columns(1).Resize(.Rows.Count, 1).Offset(1, 0) _
..Cells.SpecialCells(xlCellTypeVisible).Row
End With
MsgBox nextrow
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top