Wednesday, March 20, 2013

How to Find Last Used Row and Column in a Worksheet

Excel VBA Macro to Find Last Used Row and Column in a Worksheet
Sub LastRow_UsedInSheet()

MyLastRow = ActiveSheet.Cells.Find(what:="*", SearchOrder:=xlByRows, _

SearchDirection:=xlPrevious).Row

MyLastColumn = ActiveSheet.Cells.Find(what:="*", SearchOrder:=xlByColumns, _

SearchDirection:=xlPrevious).Column

MsgBox MyLastRow & " Rows Have Used In ActiveSheet " & vbCrLf & _

MyLastColumn & " Columns Have Used In ActiveSheet "

End Sub


Example :

Note:
This method will find only the Used Rows and Columns with data.
We can use this Count while Consolidating the data from the Several Sheets into One Sheet.

Thanks,TAMATAM

No comments:

Post a Comment

Hi User, Thank You for visiting My Blog. Please post your genuine Feedback or comments only related to this Blog Posts. Please do not post any Spam comments or Advertising kind of comments which will be Ignored.