'VBA code to apply formatting and data validation macros to all worksheets except first three
I am new to the forum and VBA codes. I have been searching for an answer to this question and am completely lost. I have a workbook that contains around 36 worksheets. I have created a macro to apply conditional formatting and data validation to one sheet and have managed to combine these two into one macro; however I want to be able to run a macro to apply this to all sheets except the first three sheets (so to the other 33 sheets who all have different names). So far I have not had any luck. Any suggestions would be appreciated. Thanks! enter image description here I am not fussed how it works e.g. calling the combined macro code, calling the individual codes or calling the full codes, I have provided these below.
Code for Conditional Formatting Macro
`Sub Conditional_Formatting()
Code for Data Validation Macro
Sub Data_Validation()
Solution 1:[1]
Welcome to the site.
You can address and read excel sheets by their number wb.sheets(1) you don't have to use the name of the sheet.
So with that you could, in your loop, check if the number or Index is 1, 2 or 3.
if (sh.Index > 3) then
...
Your code
...
End if
where sh is the sheet reference.
This snip executes your code if the sheet index is greater than 3
Hope that makes sense.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Kristian Schmidt Larsen |
