Hi,
I'm writing a bit of a code that will re-format all sheets in spreadsheet except the three named. I keep on getting compile errors whatever I do. It's driven me mad.
Could you please have a look at this and tell me what the heck is wrong?
Sub formatsandsortall()
Dim ws As Worksheet
For Each ws In Worksheets
If ActiveSheet.Name <> "name1" And ActiveSheet.Name <> "name2" And ActiveSheet.Name <> "name3" Then _
Worksheets("ws").Select
ActiveSheet.Cells.Select
Selection.ClearFormats
Selection.NumberFormat = "@"
Columns("A:K").Select
ActiveSheet.Sort.SortFields.clear
ActiveSheet.Sort.SortFields.Add Key:=Range( _
"A1"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortTextAsNumbers
With ActiveSheet.Sort
.SetRange Range("A:K")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End If
Next ws
End Sub
Thanks a million!
Bookmarks