PC Review


Reply
Thread Tools Rate Thread

Determining the Active Worksheet

 
 
ordnance1
Guest
Posts: n/a
 
      15th Apr 2010
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

 
Reply With Quote
 
 
 
 
Wouter HM
Guest
Posts: n/a
 
      15th Apr 2010
Hi ordnance1,

For your first line you can use:

If ActiveSheet.Name = "April" Then

HTH,

Wouter
 
Reply With Quote
 
Don Guillett
Guest
Posts: n/a
 
      15th Apr 2010
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
(E-Mail Removed)
"ordnance1" <(E-Mail Removed)> wrote in message
news:98E102AB-861E-4C28-AB8C-(E-Mail Removed)...
> 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


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Determining last active cell in a protected worksheet =?Utf-8?B?UGF1bA==?= Microsoft Excel Programming 2 10th Aug 2006 05:40 PM
Determining an active application =?Utf-8?B?Q2hhcmxlcyBUYW0=?= Microsoft Access Form Coding 3 18th Nov 2004 11:40 AM
Determining the Active Control Joe Hanna Microsoft Dot NET Compact Framework 2 18th Jan 2004 07:15 AM
Re: Determining Active Row Number Don Guillett Microsoft Excel Programming 0 20th Aug 2003 11:04 PM
Determining Active Row Number Scott Patrias Microsoft Excel Programming 0 20th Aug 2003 09:14 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:51 AM.