![]() |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
All times are GMT +1. The time now is 12:35 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com