Simple answer, I'm sure, but I can't figure this out. My code is:
I want to be able to run this from any sheet (and have it sort columns A:L on sheet 'Clean'.)
The problem is that it sorts cols A:L on whatever sheet I have selected/in focus.
I thought the With Sheets("clean") / End With instructed the VBA to perform the action on sheet 'clean' regardless of what sheet is in focuse...but that's obviously not happening, so what am I doing wrong?
VBA Code:
Sub clean_sheet_sort()
With Sheets("clean")
Dim LastRow As Long
LastRow = Cells(Rows.Count, 1).End(xlUp).Row
Range("A1:L" & LastRow).sort Key1:=Range("A1:A" & LastRow), _
Order1:=xlAscending, Header:=xlYes
End With
End Sub
I want to be able to run this from any sheet (and have it sort columns A:L on sheet 'Clean'.)
The problem is that it sorts cols A:L on whatever sheet I have selected/in focus.
I thought the With Sheets("clean") / End With instructed the VBA to perform the action on sheet 'clean' regardless of what sheet is in focuse...but that's obviously not happening, so what am I doing wrong?