Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
I have a procedure that formats Worksheet1 when something happens in a certain cell. Worksheet1 is titled: APPLES. The procedure I have for this works great. Working part of the procedure I have now looks like this: With Worksheets("APPLES") Hide rows, change font color etc. I would now also like to have the same thing happen in Worksheet2. Worksheet2 is called ORANGES. Something like: With Worksheets("APPLES & ORANGES").... Is is possible to have mutiple worksheets follow the same procedure? Thank you for your time, Amy |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
*Method one
Dim varSheets As Variant Dim i as Integer varSheets = Array("Apples", "Oranges") For i = lbound(varsheets) to ubound(varsheets) With Worksheets(varSheets(i)) '..........your code End With Next i *Method two Dim wks as Worksheet For Each wks in Worksheets Select Case wks.Name Case "Apples", "Oranges" With wks '.........your code End With Case Else 'Do nothing End Select Next wks HTH, "AMY Z." wrote in message ... Hi, I have a procedure that formats Worksheet1 when something happens in a certain cell. Worksheet1 is titled: APPLES. The procedure I have for this works great. Working part of the procedure I have now looks like this: With Worksheets("APPLES") Hide rows, change font color etc. I would now also like to have the same thing happen in Worksheet2. Worksheet2 is called ORANGES. Something like: With Worksheets("APPLES & ORANGES").... Is is possible to have mutiple worksheets follow the same procedure? Thank you for your time, Amy |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Here is one method
for each ws in worksheets if (ws.name = "APPLES") OR (ws.name = "ORANGES") then with worksheets(ws.name) 'put your code here end with end if next ws "AMY Z." wrote: Hi, I have a procedure that formats Worksheet1 when something happens in a certain cell. Worksheet1 is titled: APPLES. The procedure I have for this works great. Working part of the procedure I have now looks like this: With Worksheets("APPLES") Hide rows, change font color etc. I would now also like to have the same thing happen in Worksheet2. Worksheet2 is called ORANGES. Something like: With Worksheets("APPLES & ORANGES").... Is is possible to have mutiple worksheets follow the same procedure? Thank you for your time, Amy |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
A macro code to print multiple sheets in different w.books | Excel Discussion (Misc queries) | |||
Help on VBA Code to populate multiple sheets | Excel Discussion (Misc queries) | |||
change code to work over multiple sheets | Excel Programming | |||
Rename Multiple Sheets - Help with Mr Dave Peterson's Code | Excel Programming | |||
Sort Sheets Procedure | Excel Programming |