how to find maximum rows of the sheet of workbook - vba

Viewed 18942

I want to get the data from the workbook which contain the multiple sheets and dont know which sheet having the data. So need to check the used rows count of the every sheet of the workbook and activate the sheet which contain maximum used rows for getting the data. struct with below code and any suggestion would appreciate.

Sub Maxdatasheet()
Dim wscount As Integer
Dim myArray() As Variant

wscount = ActiveWorkbook.Worksheets.Count

  For i = 1 To wscount
    myArray(i) = Worksheets(i).UsedRange.Rows.Count
    Next
    'need to activate the maximus rows of the sheet
End Sub
4 Answers
Related