Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
I have a macro that contains the line:
With Worksheets("UK") Can I get it to apply to all my worksheets? Ie With Worksheets(All) Thanks! |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Use something like With Worksheets(Activesheet)
this will work with any worksheet. There is no worksheets(All) as all the worksheets is really the workbook collection DannyS wrote: I have a macro that contains the line: With Worksheets("UK") Can I get it to apply to all my worksheets? Ie With Worksheets(All) Thanks! |
#3
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]() Great stuff, thanks again to you two guys! "PMC1" wrote: Use something like With Worksheets(Activesheet) this will work with any worksheet. There is no worksheets(All) as all the worksheets is really the workbook collection DannyS wrote: I have a macro that contains the line: With Worksheets("UK") Can I get it to apply to all my worksheets? Ie With Worksheets(All) Thanks! |
#4
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Ah, hang on. When I use Activesheets I get a runtime error. My macro looks
like this: Sub auto_open() With Worksheets(ActiveSheet) .Protect Password:="hi", userinterfaceonly:=True .EnableOutlining = True '.EnableAutoFilter = True End With End Sub "PMC1" wrote: Use something like With Worksheets(Activesheet) this will work with any worksheet. There is no worksheets(All) as all the worksheets is really the workbook collection DannyS wrote: I have a macro that contains the line: With Worksheets("UK") Can I get it to apply to all my worksheets? Ie With Worksheets(All) Thanks! |
#5
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
maybe.......
With Activesheet Vaya con Dios, Chuck, CABGx3 "DannyS" wrote: Ah, hang on. When I use Activesheets I get a runtime error. My macro looks like this: Sub auto_open() With Worksheets(ActiveSheet) .Protect Password:="hi", userinterfaceonly:=True .EnableOutlining = True '.EnableAutoFilter = True End With End Sub "PMC1" wrote: Use something like With Worksheets(Activesheet) this will work with any worksheet. There is no worksheets(All) as all the worksheets is really the workbook collection DannyS wrote: I have a macro that contains the line: With Worksheets("UK") Can I get it to apply to all my worksheets? Ie With Worksheets(All) Thanks! |
#6
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
In the same way that you can not select multipe sheets and protect them
manually, you can not have VBA protect multiple sheets at once. What you can do is have VBA cycle through all of the sheets and process them one at a time something like this... Sub auto_open() dim wks as worksheet for each wks in worksheets with wks .Protect Password:="hi", userinterfaceonly:=True .EnableOutlining = True '.EnableAutoFilter = True End With next wks End Sub -- HTH... Jim Thomlinson "DannyS" wrote: Ah, hang on. When I use Activesheets I get a runtime error. My macro looks like this: Sub auto_open() With Worksheets(ActiveSheet) .Protect Password:="hi", userinterfaceonly:=True .EnableOutlining = True '.EnableAutoFilter = True End With End Sub "PMC1" wrote: Use something like With Worksheets(Activesheet) this will work with any worksheet. There is no worksheets(All) as all the worksheets is really the workbook collection DannyS wrote: I have a macro that contains the line: With Worksheets("UK") Can I get it to apply to all my worksheets? Ie With Worksheets(All) Thanks! |
#7
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]() Yes! Great stuff - thanks Jim! "Jim Thomlinson" wrote: In the same way that you can not select multipe sheets and protect them manually, you can not have VBA protect multiple sheets at once. What you can do is have VBA cycle through all of the sheets and process them one at a time something like this... Sub auto_open() dim wks as worksheet for each wks in worksheets with wks .Protect Password:="hi", userinterfaceonly:=True .EnableOutlining = True '.EnableAutoFilter = True End With next wks End Sub -- HTH... Jim Thomlinson "DannyS" wrote: Ah, hang on. When I use Activesheets I get a runtime error. My macro looks like this: Sub auto_open() With Worksheets(ActiveSheet) .Protect Password:="hi", userinterfaceonly:=True .EnableOutlining = True '.EnableAutoFilter = True End With End Sub "PMC1" wrote: Use something like With Worksheets(Activesheet) this will work with any worksheet. There is no worksheets(All) as all the worksheets is really the workbook collection DannyS wrote: I have a macro that contains the line: With Worksheets("UK") Can I get it to apply to all my worksheets? Ie With Worksheets(All) Thanks! |
#8
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
maybe.......
With Activesheet Vaya con Dios, Chuck, CABGx3 "DannyS" wrote: I have a macro that contains the line: With Worksheets("UK") Can I get it to apply to all my worksheets? Ie With Worksheets(All) Thanks! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Same macro - Different Worksheets!? | Excel Discussion (Misc queries) | |||
Copying data to multiple worksheets by Macro | Excel Discussion (Misc queries) | |||
automatically apply a macro to all worksheets | Excel Discussion (Misc queries) | |||
Applying same macro to all worksheets in workbook | Excel Discussion (Misc queries) | |||
CREATE MACRO TO COPY MULTIPLE WORKSHEETS | Excel Discussion (Misc queries) |