Hello all,
Been building some basic macro's and started on a more complex one (below) when I left it last, it would run fine and do what I want. Since I've come back to it though it has stopped working and comes up with the Compile Error: Expected End With and End Sub is highlighted.
Could someone explain (in simple as possible way) what the error actually means and also point to where it is going wrong/how to fix?
Thanks in advance for any help provided.
Public Sub Michelle()
'
' Macro for Michelle
ActiveWorkbook.Worksheets("March Other Sources").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("March Other Sources").Sort.SortFields.Add Key:= _
Range("U5:U5000"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption _
:=xlSortNormal
ActiveWorkbook.Worksheets("March Other Sources").Sort.SortFields.Add Key:= _
Range("G5:G5000"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption _
:=xlSortNormal
With ActiveWorkbook.Worksheets("March Other Sources").Sort
.SetRange Range("A4:AF5000")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
Sheets("March Other Sources").Select
Columns("U:U").Select
Selection.Copy
Sheets("Unique Values").Select
Columns("A:A").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
ActiveSheet.Range("$A$1:$A$967").RemoveDuplicates Columns:=1, Header:=xlNo
Columns("A").Replace What:="/", _
Replacement:="&", _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
MatchCase:=False, _
SearchFormat:=False, _
ReplaceFormat:=False
Dim MyCell As Range, MyRange As Range
Set MyRange = Sheets("Unique Values").Range("A3")
Set MyRange = Range(MyRange, MyRange.End(xlDown))
For Each MyCell In MyRange
Sheets.Add After:=Sheets(Sheets.Count) 'creates a new worksheet
Sheets(Sheets.Count).Name = MyCell.Value ' renames the new worksheet
Next MyCell
End Sub
Been building some basic macro's and started on a more complex one (below) when I left it last, it would run fine and do what I want. Since I've come back to it though it has stopped working and comes up with the Compile Error: Expected End With and End Sub is highlighted.
Could someone explain (in simple as possible way) what the error actually means and also point to where it is going wrong/how to fix?
Thanks in advance for any help provided.
Public Sub Michelle()
'
' Macro for Michelle
ActiveWorkbook.Worksheets("March Other Sources").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("March Other Sources").Sort.SortFields.Add Key:= _
Range("U5:U5000"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption _
:=xlSortNormal
ActiveWorkbook.Worksheets("March Other Sources").Sort.SortFields.Add Key:= _
Range("G5:G5000"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption _
:=xlSortNormal
With ActiveWorkbook.Worksheets("March Other Sources").Sort
.SetRange Range("A4:AF5000")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
Sheets("March Other Sources").Select
Columns("U:U").Select
Selection.Copy
Sheets("Unique Values").Select
Columns("A:A").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
ActiveSheet.Range("$A$1:$A$967").RemoveDuplicates Columns:=1, Header:=xlNo
Columns("A").Replace What:="/", _
Replacement:="&", _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
MatchCase:=False, _
SearchFormat:=False, _
ReplaceFormat:=False
Dim MyCell As Range, MyRange As Range
Set MyRange = Sheets("Unique Values").Range("A3")
Set MyRange = Range(MyRange, MyRange.End(xlDown))
For Each MyCell In MyRange
Sheets.Add After:=Sheets(Sheets.Count) 'creates a new worksheet
Sheets(Sheets.Count).Name = MyCell.Value ' renames the new worksheet
Next MyCell
End Sub