I have a Sub to sort sheets by due date (D:D)
As each sheet is selected the sheetcode activate calls the sort routine.
This works
Sub Sdate(wsName As String)
Dim ws1 As Worksheet
Set ws1 = Sheets(wsName)
Range("A3:J250").Select
Sheets("April").Sort.SortFields.Clear
Sheets("April").Sort.SortFields.Add Key:=Range("D3:D250"), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With Sheets("April").Sort
.SetRange Range("A3:J250")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub
if manually plug in the sheet name
This doesn't
Sub Sdate(wsName As String)
Dim ws1 As Worksheet
Set ws1 = Sheets(wsName)
Range("A3:J250").Select
Sheets(ws1).Sort.SortFields.Clear
Sheets(ws1).Sort.SortFields.Add Key:=Range("D3:D250"), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With Sheets(ws1).Sort
.SetRange Range("A3:J250")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub
Called with
The immediate window does show ws1 = "April"
Also how do you turn off the highlight after the range selection?
Please point out my ignorance.
thanks
Bookmarks