Hi all,
I have a macro that applies borders and conditional formatting to a sheet based on a cell value. The Workbook has 20+ worksheets and the sheet names may change. I am looking for a macro that will apply the below code it to all worksheets except for 'Sheet1', 'Sheet2' and 'Sheet3'.
Sheets("Sample").Select
If Range("A3").Value > "0" Then Call add
.
.
Sub add()
'add border
Cells.Select
Selection.Borders.LineStyle = xlNone
Range("A2").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
With Selection.Borders
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
'apply conditional formatting
Range("A3:U3").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=MOD(ROW(),2)=0"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorLight2
.TintAndShade = 0.799981688894314
End With
Selection.FormatConditions(1).StopIfTrue = False
End Sub
I believe that the code I am looking for, has to start w/
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
but I don't know how to adjust the above code.
Any help is much appreciated.
Thanks
Bookmarks