How can I edit this macro to exclude 3 sheet names?

tonywatsonhelp

Well-known Member
Joined
Feb 24, 2014
Messages
3,201
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Hi Everyone,

I have this macro that resets the fonts on every sheet to black

it works great but I've just realised I don't want it to change the Dashboard sheets,

Is there a way to edit it (or start again if you have better ideas) so that it runs on all sheets unless they contain the word "Dashboard" in there sheet name
so "Master Dashboard" or "Sales Dashboard" etc would be unaffected?

Here's my code

Thanks

Tony


Code:
[FONT=Calibri][SIZE=3][COLOR=#000000]Sub Fontcolour()[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]    Dim ws AsWorksheet[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]    On Error ResumeNext[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]        For Each wsIn ActiveWorkbook.Worksheets[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]    With ws[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]Old = ws.Cells(Rows.Count, "A").End(xlUp).Row[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]Range("A2:R" & Old).Font.ThemeColor =xlThemeColorLight1[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]End With[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]Next[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]End Sub[/COLOR][/SIZE][/FONT]
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Something like
Code:
[LEFT][COLOR=#333333][FONT=Calibri][SIZE=3][COLOR=#000000]Sub Fontcolour()[/COLOR][/SIZE][/FONT][/COLOR][COLOR=#333333][FONT=monospace]
[/FONT][/COLOR][COLOR=#333333][FONT=Calibri][SIZE=3][COLOR=#000000]    Dim ws AsWorksheet[/COLOR][/SIZE][/FONT][/COLOR][COLOR=#333333][FONT=monospace]
[/FONT][/COLOR][COLOR=#333333][FONT=Calibri][SIZE=3][COLOR=#000000]    On Error ResumeNext[/COLOR][/SIZE][/FONT][/COLOR][COLOR=#333333][FONT=monospace]
[/FONT][/COLOR][COLOR=#333333][FONT=Calibri][SIZE=3][COLOR=#000000]        For Each wsIn ActiveWorkbook.Worksheets
If (ws.name<>sheets("Dashboard1").name and ws.name<>sheets("Dashboard2").name and ws.name<>sheets("Dashboard3").name) then[/COLOR][/SIZE][/FONT][/COLOR][COLOR=#333333][FONT=monospace]
[/FONT][/COLOR][COLOR=#333333][FONT=Calibri][SIZE=3][COLOR=#000000]    With ws[/COLOR][/SIZE][/FONT][/COLOR][COLOR=#333333][FONT=monospace]
[/FONT][/COLOR][COLOR=#333333][FONT=Calibri][SIZE=3][COLOR=#000000]Old = ws.Cells(Rows.Count, "A").End(xlUp).Row[/COLOR][/SIZE][/FONT][/COLOR][COLOR=#333333][FONT=monospace]
[/FONT][/COLOR][COLOR=#333333][FONT=Calibri][SIZE=3][COLOR=#000000]Range("A2:R" & Old).Font.ThemeColor =xlThemeColorLight1[/COLOR][/SIZE][/FONT][/COLOR][COLOR=#333333][FONT=monospace]
[/FONT][/COLOR][COLOR=#333333][FONT=Calibri][SIZE=3][COLOR=#000000]End With
End if[/COLOR][/SIZE][/FONT][/COLOR][COLOR=#333333][FONT=monospace]
[/FONT][/COLOR][COLOR=#333333][FONT=Calibri][SIZE=3][COLOR=#000000]Next[/COLOR][/SIZE][/FONT][/COLOR][COLOR=#333333][FONT=monospace]
[/FONT][/COLOR][COLOR=#333333][FONT=Calibri][SIZE=3][COLOR=#000000]End Sub
[/COLOR][/SIZE][/FONT][/COLOR][/LEFT]
 
Upvote 0
Another option
Code:
Sub Fontcolour()
   Dim ws As Worksheet
   For Each ws In ActiveWorkbook.Worksheets
      If Not LCase(ws.Name) Like "*dashboard*" Then
         Old = ws.Cells(Rows.Count, "A").End(xlUp).Row
         ws.Range("A2:R" & Old).Font.ThemeColor = xlThemeColorLight1
      End If
   Next
End Sub
 
Upvote 0

Forum statistics

Threads
1,216,080
Messages
6,128,692
Members
449,464
Latest member
againofsoul

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top