View Single Post
 
Old 01-17-2024, 09:58 AM
rollis13's Avatar
rollis13 rollis13 is offline Windows 11 Office 2016
Competent Performer
 
Join Date: Jan 2021
Location: Cordenons
Posts: 142
rollis13 will become famous soon enough
Default

This could be a basic macro that you can upgrade as needed. As it is the folder name is static (no subfolders) and will change the right-foot only on the first sheet of each file.
Code:
Option Explicit
Sub UpdateRightFooter()
    Dim wkb   As Workbook
    Dim sht   As Worksheet
    Dim myPath As String
    Dim strFile As String
    Dim cnt   As Long
    Application.ScreenUpdating = False
    Application.DisplayAlerts = False
    Application.EnableEvents = False
    Application.StatusBar = "Macro at work ... please wait"
    myPath = "F:\Prove\Test\"                     '<- adjust path as needed
    strFile = Dir(myPath & "*.xls*")              'for all sort of Excel files
    Do While Len(strFile) > 0
        Workbooks.Open (myPath & strFile)
        Set wkb = ActiveWorkbook
        Set sht = wkb.Worksheets(1)               'only for first sheet in file
        sht.PageSetup.RightFooter = "New Form Number" '<- adjust string as needed
        cnt = cnt + 1
        wkb.Close True
        strFile = Dir
    Loop
    Application.ScreenUpdating = True
    Application.DisplayAlerts = True
    Application.EnableEvents = True
    Application.StatusBar = Empty
    MsgBox "Done! for " & cnt & " files"
End Sub
__________________
Difficult is not to know but to share what you know (Han Fei Tzu reworked)
Reply With Quote