aggiemarine07
New Member
- Joined
- Nov 5, 2013
- Messages
- 46
Howdy! I am definitetly a novice at VBA and I am hoping someone with more VBA skills than myself can spot the error below. I keep getting a "Compile Error: Expected End With" error. This code is supposed to auto sort data in a few columns as information gets added. Here is the code:
Any help would be greatly appreciated. Thanks!
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Range("P5:Y156").Select
ActiveWorkbook.Worksheets("COMBINED").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("COMBINED").Sort.SortFields.Add Key:=Range( _
"P5:P156"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
ActiveWorkbook.Worksheets("COMBINED").Sort.SortFields.Add Key:=Range( _
"R5:R156"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("COMBINED").Sort
.SetRange Range("P4:Y156")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End Sub
Any help would be greatly appreciated. Thanks!
Last edited by a moderator: