J
jfcby
Hello,
The vba code below works as is. But, I need to make changes and since
the code is so long it would take a while to make the neccessary
changes.
Each If statement is almost the same but I'll need to change the year.
Can this code be combined to be more efficent? If not, is there a way
to make make the changes using vba code?
THE VBA CODE:
Sub Select_Cal_Options_Macros_Preview()
If Sheet4.Range("B1") = 2 Then
Sheets("January 2006 NORTH").Select
Application.Run ("SetSelect_CalOptions")
End If
If Sheet4.Range("B1") = 3 Then
Sheets("February 2006 NORTH").Select
Application.Run ("SetSelect_CalOptions")
End If
If Sheet4.Range("B1") = 4 Then
Sheets("March 2006 NORTH").Select
Application.Run ("SetSelect_CalOptions")
End If
If Sheet4.Range("B1") = 5 Then
Sheets("April 2006 NORTH").Select
Application.Run ("SetSelect_CalOptions")
End If
If Sheet4.Range("B1") = 6 Then
Sheets("May 2006 NORTH").Select
Application.Run ("SetSelect_CalOptions")
End If
If Sheet4.Range("B1") = 7 Then
Sheets("June 2006 NORTH").Select
Application.Run ("SetSelect_CalOptions")
End If
If Sheet4.Range("B1") = 8 Then
Sheets("July 2006 NORTH").Select
Application.Run ("SetSelect_CalOptions")
End If
If Sheet4.Range("B1") = 9 Then
Sheets("August 2006 NORTH").Select
Application.Run ("SetSelect_CalOptions")
End If
If Sheet4.Range("B1") = 10 Then
Sheets("September 2006 NORTH").Select
Application.Run ("SetSelect_CalOptions")
End If
If Sheet4.Range("B1") = 11 Then
Sheets("October 2006 NORTH").Select
Application.Run ("SetSelect_CalOptions")
End If
If Sheet4.Range("B1") = 12 Then
Sheets("November 2006 NORTH").Select
Application.Run ("SetSelect_CalOptions")
End If
If Sheet4.Range("B1") = 13 Then
Sheets("December 2006 NORTH").Select
Application.Run ("SetSelect_CalOptions")
End If
If Sheet4.Range("B1") = 14 Then
Sheets("January 2006 SOUTH").Select
Application.Run ("SetSelect_CalOptions")
End If
If Sheet4.Range("B1") = 15 Then
Sheets("February 2006 SOUTH").Select
Application.Run ("SetSelect_CalOptions")
End If
If Sheet4.Range("B1") = 16 Then
Sheets("March 2006 SOUTH").Select
Application.Run ("SetSelect_CalOptions")
End If
If Sheet4.Range("B1") = 17 Then
Sheets("April 2006 SOUTH").Select
Application.Run ("SetSelect_CalOptions")
End If
If Sheet4.Range("B1") = 18 Then
Sheets("May 2006 SOUTH").Select
Application.Run ("SetSelect_CalOptions")
End If
If Sheet4.Range("B1") = 19 Then
Sheets("June 2006 SOUTH").Select
Application.Run ("SetSelect_CalOptions")
End If
If Sheet4.Range("B1") = 20 Then
Sheets("July 2006 SOUTH").Select
Application.Run ("SetSelect_CalOptions")
End If
If Sheet4.Range("B1") = 21 Then
Sheets("August 2006 SOUTH").Select
Application.Run ("SetSelect_CalOptions")
End If
If Sheet4.Range("B1") = 22 Then
Sheets("September 2006 SOUTH").Select
Application.Run ("SetSelect_CalOptions")
End If
If Sheet4.Range("B1") = 23 Then
Sheets("October 2006 SOUTH").Select
Application.Run ("SetSelect_CalOptions")
End If
If Sheet4.Range("B1") = 24 Then
Sheets("November 2006 SOUTH").Select
Application.Run ("SetSelect_CalOptions")
End If
If Sheet4.Range("B1") = 25 Then
Sheets("December 2006 SOUTH").Select
Application.Run ("SetSelect_CalOptions")
End If
End Sub
Thank you for your help in advance,
jfcby
The vba code below works as is. But, I need to make changes and since
the code is so long it would take a while to make the neccessary
changes.
Each If statement is almost the same but I'll need to change the year.
Can this code be combined to be more efficent? If not, is there a way
to make make the changes using vba code?
THE VBA CODE:
Sub Select_Cal_Options_Macros_Preview()
If Sheet4.Range("B1") = 2 Then
Sheets("January 2006 NORTH").Select
Application.Run ("SetSelect_CalOptions")
End If
If Sheet4.Range("B1") = 3 Then
Sheets("February 2006 NORTH").Select
Application.Run ("SetSelect_CalOptions")
End If
If Sheet4.Range("B1") = 4 Then
Sheets("March 2006 NORTH").Select
Application.Run ("SetSelect_CalOptions")
End If
If Sheet4.Range("B1") = 5 Then
Sheets("April 2006 NORTH").Select
Application.Run ("SetSelect_CalOptions")
End If
If Sheet4.Range("B1") = 6 Then
Sheets("May 2006 NORTH").Select
Application.Run ("SetSelect_CalOptions")
End If
If Sheet4.Range("B1") = 7 Then
Sheets("June 2006 NORTH").Select
Application.Run ("SetSelect_CalOptions")
End If
If Sheet4.Range("B1") = 8 Then
Sheets("July 2006 NORTH").Select
Application.Run ("SetSelect_CalOptions")
End If
If Sheet4.Range("B1") = 9 Then
Sheets("August 2006 NORTH").Select
Application.Run ("SetSelect_CalOptions")
End If
If Sheet4.Range("B1") = 10 Then
Sheets("September 2006 NORTH").Select
Application.Run ("SetSelect_CalOptions")
End If
If Sheet4.Range("B1") = 11 Then
Sheets("October 2006 NORTH").Select
Application.Run ("SetSelect_CalOptions")
End If
If Sheet4.Range("B1") = 12 Then
Sheets("November 2006 NORTH").Select
Application.Run ("SetSelect_CalOptions")
End If
If Sheet4.Range("B1") = 13 Then
Sheets("December 2006 NORTH").Select
Application.Run ("SetSelect_CalOptions")
End If
If Sheet4.Range("B1") = 14 Then
Sheets("January 2006 SOUTH").Select
Application.Run ("SetSelect_CalOptions")
End If
If Sheet4.Range("B1") = 15 Then
Sheets("February 2006 SOUTH").Select
Application.Run ("SetSelect_CalOptions")
End If
If Sheet4.Range("B1") = 16 Then
Sheets("March 2006 SOUTH").Select
Application.Run ("SetSelect_CalOptions")
End If
If Sheet4.Range("B1") = 17 Then
Sheets("April 2006 SOUTH").Select
Application.Run ("SetSelect_CalOptions")
End If
If Sheet4.Range("B1") = 18 Then
Sheets("May 2006 SOUTH").Select
Application.Run ("SetSelect_CalOptions")
End If
If Sheet4.Range("B1") = 19 Then
Sheets("June 2006 SOUTH").Select
Application.Run ("SetSelect_CalOptions")
End If
If Sheet4.Range("B1") = 20 Then
Sheets("July 2006 SOUTH").Select
Application.Run ("SetSelect_CalOptions")
End If
If Sheet4.Range("B1") = 21 Then
Sheets("August 2006 SOUTH").Select
Application.Run ("SetSelect_CalOptions")
End If
If Sheet4.Range("B1") = 22 Then
Sheets("September 2006 SOUTH").Select
Application.Run ("SetSelect_CalOptions")
End If
If Sheet4.Range("B1") = 23 Then
Sheets("October 2006 SOUTH").Select
Application.Run ("SetSelect_CalOptions")
End If
If Sheet4.Range("B1") = 24 Then
Sheets("November 2006 SOUTH").Select
Application.Run ("SetSelect_CalOptions")
End If
If Sheet4.Range("B1") = 25 Then
Sheets("December 2006 SOUTH").Select
Application.Run ("SetSelect_CalOptions")
End If
End Sub
Thank you for your help in advance,
jfcby