Hi
I have this code to sort a list
Sub Alphabetise()
'
c = Sheets("Data").Range("L2").Value + 1
Sheets("Clients").Range("A3:Z" & c).Sort Key1:=Range("F3"), Order1:=xlAscending, Key2:=Range("J3") _
, Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase:= _
False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, DataOption2 _
:=xlSortNormal
End Sub
My problem is that it will only work if the sheet, Clients, is the active worksheet. If any other worksheet is active when it runs I get an error. Can anybody tell me why? And, more importantly, can anyone tell me how to make it work in the background or make the Clients worksheet active without making it visible?
Thanks
I have this code to sort a list
Sub Alphabetise()
'
c = Sheets("Data").Range("L2").Value + 1
Sheets("Clients").Range("A3:Z" & c).Sort Key1:=Range("F3"), Order1:=xlAscending, Key2:=Range("J3") _
, Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase:= _
False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, DataOption2 _
:=xlSortNormal
End Sub
My problem is that it will only work if the sheet, Clients, is the active worksheet. If any other worksheet is active when it runs I get an error. Can anybody tell me why? And, more importantly, can anyone tell me how to make it work in the background or make the Clients worksheet active without making it visible?
Thanks