From: ordnance1 on
My problem here is of course in line 1. I need the code to run based on what
worksheet is active. There will be a series of these if statements (if May
is active I will select May - September and so on). So is there any way to
write the first line to determine the active worksheet?


Sub Macro2()

If Worksheets("April").Active = True Then

Sheets(Array("April", "May", "June", "July", "August",
"September")).Select

End If

End Sub

From: Wouter HM on
Hi ordnance1,

For your first line you can use:

If ActiveSheet.Name = "April" Then

HTH,

Wouter
From: Don Guillett on
if activeworksheet.name="April" then
do this
else
do that
end if

Or instead of selecting, just do what you need to do for sheet2(Jan) to
sheet13(Dec)
Sub dorestofsheets()
'MsgBox ActiveSheet.Index
For i = ActiveSheet.Index To 13
Sheets(i).Range("a1") = 1
Next i
End Sub


--
Don Guillett
Microsoft MVP Excel
SalesAid Software
dguillett(a)gmail.com
"ordnance1" <ordnance1(a)comcast.net> wrote in message
news:98E102AB-861E-4C28-AB8C-6B3260B83A15(a)microsoft.com...
> My problem here is of course in line 1. I need the code to run based on
> what worksheet is active. There will be a series of these if statements
> (if May is active I will select May - September and so on). So is there
> any way to write the first line to determine the active worksheet?
>
>
> Sub Macro2()
>
> If Worksheets("April").Active = True Then
>
> Sheets(Array("April", "May", "June", "July", "August",
> "September")).Select
>
> End If
>
> End Sub