ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Problem with offsetting one row down (https://www.excelbanter.com/excel-programming/442952-problem-offsetting-one-row-down.html)

Raj[_2_]

Problem with offsetting one row down
 
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





Per Jessen

Problem with offsetting one row down
 
Insert the line below after the line mentioned:

If NextRow=2 then NextRow=3

Regards,
Per

"Raj" skrev i meddelelsen
...
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





Don Guillett[_2_]

Problem with offsetting one row down
 
Sub lastcell()
nextrow = .Columns(1).Resize(.Rows.Count, 1).Offset(1, 0) _
..Cells.SpecialCells(xlCellTypeVisible).Row
End With
MsgBox nextrow
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Raj" wrote in message
...
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







All times are GMT +1. The time now is 03:29 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com