VBA code to exclude specific tabs

Carl C

New Member
Joined
May 17, 2018
Messages
1
Hi

I am trying to have a code to add a header to all tabs except 2 tabs "Control" and "Cover" I am not sure how to insert the code to make this work.

here is my code for the inserting the header
Code:
Sub Update_header()
    Dim WS As Worksheet
    Dim HeaderText As String
   HeaderText = "&""Calibri,bold italic""&11" & "&K021128" & strHeader & Format(Sheet1.Range("e19"))
    For Each WS In Worksheets
       WS.PageSetup.RightHeader = HeaderText
  
    Next
End Sub

I hope someone can help me out

Kind Regards
Carl
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Hi & welcome to MrExcel.
try
Code:
Sub Update_header()
    Dim WS As Worksheet
    Dim HeaderText As String
   HeaderText = "&""Calibri,bold italic""&11" & "&K021128" & strHeader & format(Sheet1.Range("e19"))
   For Each WS In Worksheets
     If WS.Name <> "Control" And WS.Name <> "Cover" Then
        WS.PageSetup.RightHeader = HeaderText
     End If
   Next
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,808
Messages
6,121,681
Members
449,048
Latest member
81jamesacct

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