An error occurs in the 2nd range assignment in recct . Since you are linking to another sheet, you need to tell VBA the sheet name in both range references.
Try this instead:
With ThisWorkbook.Sheets("Sheet1") recct = .Range("B2", .Range("B2").End(xlDown)).Rows.Count End With
Alternatively this will work (albeit a bit sloppier).
recct = ThisWorkbook.Sheets("Sheet1").Range("B2", ThisWorkbook.Sheets("Sheet1").Range("B2").End(xlDown)).Rows.Count
Update
Since there is a lot of discussion about what you really mean by the number of rows per sheet, use the code above to literally start with B2 and count the number of adjacent cells directly under
However, if you want to find the last โrealโ used cell in column B (essentially, I mean with the data in it), follow these steps:
With ThisWorkbook.Sheets("Sheet1") recct = .Range("B2", .Range("B" & .Rows.Count).End(xlUp)).Rows.Count End With
source share