Hi,
There are 3 worksheets named A, B and C. I want to loop thru each WS and MsgBox Count of Rows and WS Name. Weird that I keep getting same count of rows from Worksheet A in MsgBox even though the other MsgBox pops up with the 3 different sheet names.
What needs to change in code?
--------------------------------
Sub ABC()
"Declare
Dim Current As Worksheet
Dim lrow As Long
' Loop thru Worksheets A B and C and MsgBox number of rows and then MsgBox Name of Worksheet
For Each Current In Worksheets
lrow = Cells(Rows.Count, "A").End(xlUp).Row
MsgBox (Str(lrow))
lrow = 0
MsgBox Current.Name
Next
MsgBox ("complete")
End Sub
There are 3 worksheets named A, B and C. I want to loop thru each WS and MsgBox Count of Rows and WS Name. Weird that I keep getting same count of rows from Worksheet A in MsgBox even though the other MsgBox pops up with the 3 different sheet names.
What needs to change in code?
--------------------------------
Sub ABC()
"Declare
Dim Current As Worksheet
Dim lrow As Long
' Loop thru Worksheets A B and C and MsgBox number of rows and then MsgBox Name of Worksheet
For Each Current In Worksheets
lrow = Cells(Rows.Count, "A").End(xlUp).Row
MsgBox (Str(lrow))
lrow = 0
MsgBox Current.Name
Next
MsgBox ("complete")
End Sub
Last edited: