Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Macro does nothing if ran in certain worksheet?

Hello,
Is it possible to get a macro to do nothing if it is ran in a certain sheet
but to do something in the sheets it is meant for?

Thanks
--
Stu


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Macro does nothing if ran in certain worksheet?

Stu

Put your code in the sheet code not a module. Right_Click
the worksheet tab and select View code. Then cut and paste
the macro into the sheet code.

Regards
Peter
-----Original Message-----
Hello,
Is it possible to get a macro to do nothing if it is ran

in a certain sheet
but to do something in the sheets it is meant for?

Thanks
--
Stu


.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Macro does nothing if ran in certain worksheet?

My problem with doing that is I have 12 sheets, 9 of which I need a macro
that is on a toolbar to be ran but the other 3 will go very badly wrong if
the macro is ran in them any other ideas?

--
Thanks
--
Stu
"Peter Atherton" wrote in message
...
Stu

Put your code in the sheet code not a module. Right_Click
the worksheet tab and select View code. Then cut and paste
the macro into the sheet code.

Regards
Peter
-----Original Message-----
Hello,
Is it possible to get a macro to do nothing if it is ran

in a certain sheet
but to do something in the sheets it is meant for?

Thanks
--
Stu


.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Macro does nothing if ran in certain worksheet?

Just check for the activesheet at the top of the code


Select Case lcase(activesheet.name)
' sheets not to run with
Case "sheet1", "sheet5", "sheet7"
exit sub
End Select
' code continues


--
Regards,
Tom Ogilvy


Stu wrote in message
...
My problem with doing that is I have 12 sheets, 9 of which I need a macro
that is on a toolbar to be ran but the other 3 will go very badly wrong if
the macro is ran in them any other ideas?

--
Thanks
--
Stu
"Peter Atherton" wrote in message
...
Stu

Put your code in the sheet code not a module. Right_Click
the worksheet tab and select View code. Then cut and paste
the macro into the sheet code.

Regards
Peter
-----Original Message-----
Hello,
Is it possible to get a macro to do nothing if it is ran

in a certain sheet
but to do something in the sheets it is meant for?

Thanks
--
Stu


.





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Macro does nothing if ran in certain worksheet?

So where do I put the Select?

--
Thanks
--
Stu
"Tom Ogilvy" wrote in message
...
Just check for the activesheet at the top of the code


Select Case lcase(activesheet.name)
' sheets not to run with
Case "sheet1", "sheet5", "sheet7"
exit sub
End Select
' code continues


--
Regards,
Tom Ogilvy


Stu wrote in message
...
My problem with doing that is I have 12 sheets, 9 of which I need a

macro
that is on a toolbar to be ran but the other 3 will go very badly wrong

if
the macro is ran in them any other ideas?

--
Thanks
--
Stu
"Peter Atherton" wrote in message
...
Stu

Put your code in the sheet code not a module. Right_Click
the worksheet tab and select View code. Then cut and paste
the macro into the sheet code.

Regards
Peter
-----Original Message-----
Hello,
Is it possible to get a macro to do nothing if it is ran
in a certain sheet
but to do something in the sheets it is meant for?

Thanks
--
Stu


.









  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Macro does nothing if ran in certain worksheet?

Just check for the activesheet at the top of the code


Select Case lcase(activesheet.name)
' sheets not to run with
Case "sheet1", "sheet5", "sheet7"
exit sub
End Select
' code continues


--
Regards,
Tom Ogilvy

Stu wrote in message
...
My problem with doing that is I have 12 sheets, 9 of which I need a macro
that is on a toolbar to be ran but the other 3 will go very badly wrong if
the macro is ran in them any other ideas?

--
Thanks
--
Stu
"Peter Atherton" wrote in message
...
Stu

Put your code in the sheet code not a module. Right_Click
the worksheet tab and select View code. Then cut and paste
the macro into the sheet code.

Regards
Peter
-----Original Message-----
Hello,
Is it possible to get a macro to do nothing if it is ran

in a certain sheet
but to do something in the sheets it is meant for?

Thanks
--
Stu


.





  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Macro does nothing if ran in certain worksheet?

I still don't understand where because I have put it at the top of the code
and it hasn't done anything except let the macro run.

Thanks
--
Stu
"Tom Ogilvy" wrote in message
...
Just check for the activesheet at the top of the code


Select Case lcase(activesheet.name)
' sheets not to run with
Case "sheet1", "sheet5", "sheet7"
exit sub
End Select
' code continues


--
Regards,
Tom Ogilvy

Stu wrote in message
...
My problem with doing that is I have 12 sheets, 9 of which I need a

macro
that is on a toolbar to be ran but the other 3 will go very badly wrong

if
the macro is ran in them any other ideas?

--
Thanks
--
Stu
"Peter Atherton" wrote in message
...
Stu

Put your code in the sheet code not a module. Right_Click
the worksheet tab and select View code. Then cut and paste
the macro into the sheet code.

Regards
Peter
-----Original Message-----
Hello,
Is it possible to get a macro to do nothing if it is ran
in a certain sheet
but to do something in the sheets it is meant for?

Thanks
--
Stu


.







  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Macro does nothing if ran in certain worksheet?

Not sure of your expectations, but I modified an existing macro as an
example

Sub Cnvrt()
Dim cell As Range, sVal As String
Select Case LCase(ActiveSheet.Name)
' sheets not to run with
Case "sheet1", "sheet5", "sheet7"
Exit Sub
End Select
' code continues
For Each cell In Selection.SpecialCells( _
xlConstants, xlTextValues)
sVal = Trim(cell.Value)
If Right(sVal, 1) = "-" Then
cell.NumberFormat = "General"
cell.Value = CDbl(sVal)
End If
Next
End Sub

It runs on every sheet, but does nothing if the activesheet name is Sheet1,
Sheet5, Sheet7. It performs as designed if not one of those three sheets.

It is pretty straightforward. Hope you can figure it out. Of course, as I
stated, the names must match if converted to lower case.

--
Regards,
Tom Ogilvy



Stu wrote in message
...
I still don't understand where because I have put it at the top of the

code
and it hasn't done anything except let the macro run.

Thanks
--
Stu
"Tom Ogilvy" wrote in message
...
Just check for the activesheet at the top of the code


Select Case lcase(activesheet.name)
' sheets not to run with
Case "sheet1", "sheet5", "sheet7"
exit sub
End Select
' code continues


--
Regards,
Tom Ogilvy

Stu wrote in message
...
My problem with doing that is I have 12 sheets, 9 of which I need a

macro
that is on a toolbar to be ran but the other 3 will go very badly

wrong
if
the macro is ran in them any other ideas?

--
Thanks
--
Stu
"Peter Atherton" wrote in

message
...
Stu

Put your code in the sheet code not a module. Right_Click
the worksheet tab and select View code. Then cut and paste
the macro into the sheet code.

Regards
Peter
-----Original Message-----
Hello,
Is it possible to get a macro to do nothing if it is ran
in a certain sheet
but to do something in the sheets it is meant for?

Thanks
--
Stu


.









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
Macro to name worksheet tabs using a cell within the worksheet? Jennifer Excel Discussion (Misc queries) 4 November 6th 12 05:03 PM
Macro to Create New Worksheet and Reference Cell in Old Worksheet As Tab Name - "Object Required" Error [email protected] Excel Discussion (Misc queries) 4 September 25th 06 01:35 PM
How? Macro to copy range to new worksheet, name new worksheet, loop Repoman Excel Programming 9 October 9th 03 01:45 PM
macro to apply worksheet event to active worksheet Paul Simon[_2_] Excel Programming 3 August 7th 03 02:50 AM
Record Worksheet Content as Macro and Execute from another Worksheet David McRitchie[_2_] Excel Programming 2 July 23rd 03 09:43 AM


All times are GMT +1. The time now is 09:13 AM.

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"