Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 108
Default active sheet

I have a custom toolbar and on that toolbar I have a button that runs a
macro. I have the macro running on the activesheet so it runs on whatever
sheet is open at the time. The problem is that I have a chart sheet. I want
to be able to stop the macro running if the chart sheet is the active sheet.
Can anyone help?

This is my code so far:

Sub macro1()
ActiveSheet.Select
UserForm1.Show
ActiveSheet.Unprotect
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default active sheet

Sub macro1A()
If ActiveSheet.Type = xlWorksheet Then
MsgBox "It's a worksheet"
UserForm1.Show
ActiveSheet.Unprotect
Else
MsgBox "It's not a worksheet"
End If
End Sub


--
HTH,
Bernie
MS Excel MVP


"enyaw" wrote in message
...
I have a custom toolbar and on that toolbar I have a button that runs a
macro. I have the macro running on the activesheet so it runs on whatever
sheet is open at the time. The problem is that I have a chart sheet. I want
to be able to stop the macro running if the chart sheet is the active sheet.
Can anyone help?

This is my code so far:

Sub macro1()
ActiveSheet.Select
UserForm1.Show
ActiveSheet.Unprotect
End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
DS DS is offline
external usenet poster
 
Posts: 117
Default active sheet

Hi Enyaw,

Sub macro1()

ActiveSheet.Select
On Error Goto ChtFnd
Range("A1").Select
On Error Goto 0

UserForm1.Show
ActiveSheet.Unprotect
Exit Sub

ChtFnd:
End Sub

should do what you're looking for (in effect, if there is no cell "A1" to be
selected, as in a chart, it will go straight to the end of the sub, skipping
the call to the userform.)

HTH
DS


"enyaw" wrote:

I have a custom toolbar and on that toolbar I have a button that runs a
macro. I have the macro running on the activesheet so it runs on whatever
sheet is open at the time. The problem is that I have a chart sheet. I want
to be able to stop the macro running if the chart sheet is the active sheet.
Can anyone help?

This is my code so far:

Sub macro1()
ActiveSheet.Select
UserForm1.Show
ActiveSheet.Unprotect
End Sub

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 108
Default active sheet

Thanks DS.
Exactly what I was looking for.

"DS" wrote:

Hi Enyaw,

Sub macro1()

ActiveSheet.Select
On Error Goto ChtFnd
Range("A1").Select
On Error Goto 0

UserForm1.Show
ActiveSheet.Unprotect
Exit Sub

ChtFnd:
End Sub

should do what you're looking for (in effect, if there is no cell "A1" to be
selected, as in a chart, it will go straight to the end of the sub, skipping
the call to the userform.)

HTH
DS


"enyaw" wrote:

I have a custom toolbar and on that toolbar I have a button that runs a
macro. I have the macro running on the activesheet so it runs on whatever
sheet is open at the time. The problem is that I have a chart sheet. I want
to be able to stop the macro running if the chart sheet is the active sheet.
Can anyone help?

This is my code so far:

Sub macro1()
ActiveSheet.Select
UserForm1.Show
ActiveSheet.Unprotect
End Sub

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
I need to sort an active sheet using the col of the active cell HamFlyer Excel Programming 3 June 6th 06 07:25 PM
Active Cell Copy And Paste Sheet to Sheet A.R.J Allan Jefferys New Users to Excel 4 May 4th 06 02:04 AM
How do i copy a active sheet to a new sheet with code and everything Karill Excel Programming 2 April 11th 06 06:22 PM
Copy my active sheet to a new sheet and open with an input form Brad Withrow Excel Programming 0 April 6th 06 03:56 AM
Copy from active sheet and paste into new sheet using info from cell in active Ingve Excel Programming 3 January 23rd 06 09:57 PM


All times are GMT +1. The time now is 03:17 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"