VBA: Change Footer Logo Image (Right Section)

unknownymous

Board Regular
Joined
Sep 19, 2017
Messages
249
Office Version
  1. 2016
Platform
  1. Windows
Hi Guys,

I have this task which I need to update the logo image which is usually do the same for 8 tabs. I tried highlighting all the tabs but in some way it affects the formatting of the macro enabled worksheet I'm using.

8 Tabs : Results, Summary, Students, Room, Subjects, Trainor, Schedule & Others
I'm thinking of option to select tabs then update the footer logo image (on the right section) afterwards.


Any help will be much appreciated.
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Have you tried recording a macro whilst you insert and then change the footer for one of the sheets? This will show the VBA footer syntax and properties.

Try this macro, changing the image file as required:
Code:
Public Sub Change_Image_In_Footers()

    Dim wsName As Variant
    Dim imageFile As String
    
    imageFile = "C:\path\to\image.jpg"
    
    For Each wsName In Array("Results", "Summary", "Students", "Room", "Subjects", "Trainer", "Schedule", "Others")
        With ThisWorkbook.Worksheets(wsName).PageSetup
            .RightFooter = "&G"
            .RightFooterPicture.Filename = imageFile
        End With
    Next
    
End Sub
 
Upvote 0
One thing, what if one tab doesn't exist and just want to skip or ignore the error? Or to be safe, can I just select the tabs and run the macro? Thanks again.
 
Last edited:
Upvote 0
Run this on the selected tabs (grouped sheets).

Code:
Public Sub Change_Image_In_Footers2()

    Dim ws As Worksheet
    Dim imageFile As String
    
    imageFile = "C:\path\to\image.jpg"
    
    For Each ws In ActiveWindow.SelectedSheets
        With ws.PageSetup
            .RightFooter = "&G"
            .RightFooterPicture.Filename = imageFile
        End With
    Next
    
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,954
Messages
6,175,603
Members
452,658
Latest member
GStorm

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