Search This Blog

Friday 27 January 2012

CODE TO SELECT ALL DATA ON A WORKSHEET


Sub select_all()
Application.ScreenUpdating = False
Dim mylastrow As Long
Dim mylastcol As Long
Dim mylastcell, myrange
Range("A1").Select
On Error Resume Next
mylastrow = Cells.Find("*", [a1], , , xlByRows, xlPrevious).Row
mylastcol = Cells.Find("*", [a1], , , xlByColumns, xlPrevious).Column
mylastcell = Cells(mylastrow, mylastcol).Address
myrange = "a1:" & mylastcell
Application.ScreenUpdating = True
Range(myrange).Select
End Sub

No comments:

Post a Comment