Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FinalRow for multi sheet wkbook 1

Status
Not open for further replies.

sebosedszuk

Programmer
Jul 1, 2010
1
US
Sub abc()

Worksheets(Array("sheet1", "sheet2", "sheet3")).Select
With Worksheets("sheet1").Range("A1:A200")
finalrow = Cells(Rows.Count, 1).End(xlUp).Row
MsgBox "final row" & finalrow
End With



Worksheets(Array("sheet2")).Select
With Worksheets("sheet2").Range("A1:A200")
finalrow = Cells(Rows.Count, 1).End(xlUp).Row
MsgBox "final row" & finalrow
End With
End Sub

'Hello,
' Sheet1 has 6 rows, Sheet2 has 10 rows,
' but the program says 6 rows for both Sheets??
'Regards,
' Gabor
 
Code:
finalrow = [red][b].[/b][/red]Cells(Rows.Count, 1).End(xlUp).Row

When using With, you precede the object members with the Member Access Operator, which is [red].[/red]
 
In fact:
finalrow = .Cells([!].[/!]Rows.Count, 1).End(xlUp).Row

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top