Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 16
Default Apply macro to one sheet only

A macro I have written hides rows in one sheet. However, it also is hiding
the same rows in a different sheet. How do I get a macro to run in only one
sheet?
--
Marc
  #2   Report Post  
Posted to microsoft.public.excel.misc
CLR CLR is offline
external usenet poster
 
Posts: 1,998
Default Apply macro to one sheet only

Post your code, someone will help..........

Vaya con Dios,
Chuck, CABGx3



"Marcus Analyst" wrote:

A macro I have written hides rows in one sheet. However, it also is hiding
the same rows in a different sheet. How do I get a macro to run in only one
sheet?
--
Marc

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 16
Default Apply macro to one sheet only

Here is the code:

Sub Auto_Open()
'
' Auto_Open Macro
' Hides rows 10-28 (Steps 2 and 3)
'
' Keyboard Shortcut: Ctrl+x
'
Rows("10:26").Select
Selection.EntireRow.Hidden = True
End Sub
--
Marc


"CLR" wrote:

Post your code, someone will help..........

Vaya con Dios,
Chuck, CABGx3



"Marcus Analyst" wrote:

A macro I have written hides rows in one sheet. However, it also is hiding
the same rows in a different sheet. How do I get a macro to run in only one
sheet?
--
Marc

  #4   Report Post  
Posted to microsoft.public.excel.misc
CLR CLR is offline
external usenet poster
 
Posts: 1,998
Default Apply macro to one sheet only

Gary's Student just showed you.............insert this line above your "Hide
rows" line
substituting your sheet name for "Sheet2"

Sheets("Sheet2").Activate


Vaya con Dios,
Chuck, CABGx3



"Marcus Analyst" wrote:

Here is the code:

Sub Auto_Open()
'
' Auto_Open Macro
' Hides rows 10-28 (Steps 2 and 3)
'
' Keyboard Shortcut: Ctrl+x
'
Rows("10:26").Select
Selection.EntireRow.Hidden = True
End Sub
--
Marc


"CLR" wrote:

Post your code, someone will help..........

Vaya con Dios,
Chuck, CABGx3



"Marcus Analyst" wrote:

A macro I have written hides rows in one sheet. However, it also is hiding
the same rows in a different sheet. How do I get a macro to run in only one
sheet?
--
Marc

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 16
Default Apply macro to one sheet only

CLR, tried it both of these ways - name of the sheet is "current". Still
hiding rows in another sheet - is it that my macros are all in one module?
And if so, how do I put my macros into their own separate modules?

METHOD ONE:
Sub Auto_Open()
'
' Auto_Open Macro
' Hides rows 10-28 (Steps 2 and 3)
'
' Keyboard Shortcut: Ctrl+x
'
Sheets("Current").Activate
Rows("10:26").Select
Selection.EntireRow.Hidden = True
End Sub

METHOD TWO:
Sub Auto_Open()
'
' Auto_Open Macro
' Sheets("Current").Activate
' Hides rows 10-28 (Steps 2 and 3)
'
' Keyboard Shortcut: Ctrl+x
'
Rows("10:26").Select
Selection.EntireRow.Hidden = True
End Sub
--
Marc


"CLR" wrote:

Gary's Student just showed you.............insert this line above your "Hide
rows" line
substituting your sheet name for "Sheet2"

Sheets("Sheet2").Activate


Vaya con Dios,
Chuck, CABGx3



"Marcus Analyst" wrote:

Here is the code:

Sub Auto_Open()
'
' Auto_Open Macro
' Hides rows 10-28 (Steps 2 and 3)
'
' Keyboard Shortcut: Ctrl+x
'
Rows("10:26").Select
Selection.EntireRow.Hidden = True
End Sub
--
Marc


"CLR" wrote:

Post your code, someone will help..........

Vaya con Dios,
Chuck, CABGx3



"Marcus Analyst" wrote:

A macro I have written hides rows in one sheet. However, it also is hiding
the same rows in a different sheet. How do I get a macro to run in only one
sheet?
--
Marc



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 16
Default Apply macro to one sheet only

CLR, thanks for your help - but i went ahead and recorded the macro using the
following procedu

I had the file open on the sheet not to have rows hidden - we'll call it
"sheet nothide". Then I recorded the macro, first by selecting the sheet
where I wanted to have the rows hidden "sheet hide" - then selected the rows
to hide, then hid them then stopped recording. Worked like a charm!
--
Marc


"CLR" wrote:

Gary's Student just showed you.............insert this line above your "Hide
rows" line
substituting your sheet name for "Sheet2"

Sheets("Sheet2").Activate


Vaya con Dios,
Chuck, CABGx3



"Marcus Analyst" wrote:

Here is the code:

Sub Auto_Open()
'
' Auto_Open Macro
' Hides rows 10-28 (Steps 2 and 3)
'
' Keyboard Shortcut: Ctrl+x
'
Rows("10:26").Select
Selection.EntireRow.Hidden = True
End Sub
--
Marc


"CLR" wrote:

Post your code, someone will help..........

Vaya con Dios,
Chuck, CABGx3



"Marcus Analyst" wrote:

A macro I have written hides rows in one sheet. However, it also is hiding
the same rows in a different sheet. How do I get a macro to run in only one
sheet?
--
Marc

  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default Apply macro to one sheet only

Perhaps something like:

Sub hide_um()
Sheets("Sheet2").Activate
Cells(13, 1).EntireRow.Hidden = True
End Sub

--
Gary''s Student - gsnu200763


"Marcus Analyst" wrote:

A macro I have written hides rows in one sheet. However, it also is hiding
the same rows in a different sheet. How do I get a macro to run in only one
sheet?
--
Marc

  #8   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 16
Default Apply macro to one sheet only

Gary's Student, thanks for your help - but i went ahead and recorded the
macro using the following procedu

I had the file open on the sheet not to have rows hidden - we'll call it
"sheet nothide". Then I recorded the macro, first by selecting the sheet
where I wanted to have the rows hidden "sheet hide" - then selected the rows
to hide, then hid them then stopped recording. Worked like a charm!
--
Marc


"Gary''s Student" wrote:

Perhaps something like:

Sub hide_um()
Sheets("Sheet2").Activate
Cells(13, 1).EntireRow.Hidden = True
End Sub

--
Gary''s Student - gsnu200763


"Marcus Analyst" wrote:

A macro I have written hides rows in one sheet. However, it also is hiding
the same rows in a different sheet. How do I get a macro to run in only one
sheet?
--
Marc

  #9   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,345
Default Apply macro to one sheet only

Another perhaps. At the start of the code:

If ActiveSheet.Name < "Sheet2" Then Exit Sub

or you could have something like:

If ActiveSheet.Name < "Sheet2" Then
MsgBox "This Macro only works in Sheet2", , "Marcus Software"
Exit Sub
End If

--
HTH

Sandy
In Perth, the ancient capital of Scotland
and the crowning place of kings


Replace @mailinator.com with @tiscali.co.uk


"Marcus Analyst" wrote in message
...
A macro I have written hides rows in one sheet. However, it also is hiding
the same rows in a different sheet. How do I get a macro to run in only
one
sheet?
--
Marc



  #10   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 16
Default Apply macro to one sheet only

Sandy, thanks for your help - but i went ahead and recorded the macro using
the following procedu

I had the file open on the sheet not to have rows hidden - we'll call it
"sheet nothide". Then I recorded the macro, first by selecting the sheet
where I wanted to have the rows hidden "sheet hide" - then selected the rows
to hide, then hid them then stopped recording. Worked like a charm!
--
Marc


"Sandy Mann" wrote:

Another perhaps. At the start of the code:

If ActiveSheet.Name < "Sheet2" Then Exit Sub

or you could have something like:

If ActiveSheet.Name < "Sheet2" Then
MsgBox "This Macro only works in Sheet2", , "Marcus Software"
Exit Sub
End If

--
HTH

Sandy
In Perth, the ancient capital of Scotland
and the crowning place of kings


Replace @mailinator.com with @tiscali.co.uk


"Marcus Analyst" wrote in message
...
A macro I have written hides rows in one sheet. However, it also is hiding
the same rows in a different sheet. How do I get a macro to run in only
one
sheet?
--
Marc






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
how do I apply changes I make on one sheet to other sheets? Anne Excel Discussion (Misc queries) 2 December 19th 07 08:57 PM
apply a macro to all sheets except for a certain sheet minrufeng Excel Discussion (Misc queries) 4 February 22nd 06 02:53 PM
Apply Validation on a protected sheet Frederick Chow Excel Discussion (Misc queries) 0 January 3rd 06 05:56 PM
Not apply macro to every worksheet in activeworkbook G Setting up and Configuration of Excel 2 November 28th 05 05:36 PM
How to apply a macro to a protected cell greensl Excel Discussion (Misc queries) 1 August 3rd 05 04:51 PM


All times are GMT +1. The time now is 12:52 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"