W
William Bartusek
Why does the following block of code work when using a
macro button on a custom toolbar but not work when using a
control button on a worksheet??? I get a run-time error
code 1004, Method 'range of object_Worksheet' failed
pointing to the Sort block of code.
Private Sub NewScenario_Click()
'sort the "Worksheet_Name" range by Ascending order of
Scenario
Application.Worksheets("Lookup_Ranges").Activate
Application.Worksheets("Lookup_Ranges").Range
("Worksheet_Name").Activate
'sort Worksheet names by column 2 of "Worksheet_Name" range
Application.Worksheets("Lookup_Ranges").Range
("Worksheet_Name").Sort _
Key1:=Range("Worksheet_Name").Columns(2), _
Order1:=xlAscending, Header:=xlNo
'open "SetBaseline" userform
SetBaseline.Show
SetBaseline.Baseline.SetFocus
End Sub
macro button on a custom toolbar but not work when using a
control button on a worksheet??? I get a run-time error
code 1004, Method 'range of object_Worksheet' failed
pointing to the Sort block of code.
Private Sub NewScenario_Click()
'sort the "Worksheet_Name" range by Ascending order of
Scenario
Application.Worksheets("Lookup_Ranges").Activate
Application.Worksheets("Lookup_Ranges").Range
("Worksheet_Name").Activate
'sort Worksheet names by column 2 of "Worksheet_Name" range
Application.Worksheets("Lookup_Ranges").Range
("Worksheet_Name").Sort _
Key1:=Range("Worksheet_Name").Columns(2), _
Order1:=xlAscending, Header:=xlNo
'open "SetBaseline" userform
SetBaseline.Show
SetBaseline.Baseline.SetFocus
End Sub