Eric Penfold
Active Member
- Joined
- Nov 19, 2021
- Messages
- 424
- Office Version
- 365
- Platform
- Windows
- Mobile
The code turns all data in col C and E into Ref?? I think it filters OK except the before mentioned
Sub DatSrt()
Dim StRw As Integer, EndRw As Integer
Dim ws As Worksheet
Dim sort2 As String
Dim sort3 As String
Dim strSheetString As String
Set ws = ActiveSheet
With ws
StRw = 2
EndRw = .Range("A2").End(xlDown).Row
.Range("A2:P" & EndRw).ClearOutline
End With
strSheetString = EndRw
sort2 = "A1:A" & strSheetString
sort3 = "A1:P" & strSheetString
ws.Activate
ws.Sort.SortFields.Clear
ws.Sort.SortFields.Add2 Key:=Range( _
sort2), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ws.Sort
.SetRange Range(sort3)
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub
Sub DatSrt()
Dim StRw As Integer, EndRw As Integer
Dim ws As Worksheet
Dim sort2 As String
Dim sort3 As String
Dim strSheetString As String
Set ws = ActiveSheet
With ws
StRw = 2
EndRw = .Range("A2").End(xlDown).Row
.Range("A2:P" & EndRw).ClearOutline
End With
strSheetString = EndRw
sort2 = "A1:A" & strSheetString
sort3 = "A1:P" & strSheetString
ws.Activate
ws.Sort.SortFields.Clear
ws.Sort.SortFields.Add2 Key:=Range( _
sort2), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ws.Sort
.SetRange Range(sort3)
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub