Custom Footer

lord_legrand

Board Regular
Joined
Aug 21, 2010
Messages
54
Hi Guys!


I need your help in creating a macro to add a custom footer to the files that are saved on my hard disk (there's a lot of them). What I need is a macro that will the open the files that I shall choose. It would be better if I can choose multiple excel files at a time. Then if possible a dropdown will then appear containing the following values:

"Footer Label 1"
"Footer Label 2"
"Footer Label 3"
"Footer Label 4"


After that, I would then choose the appropriate dropdown and click ok (or continue?). The macro will then add a customer footer to those files based on the footer label I have chosen.


Thanks guys!!
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
You can use a userform to add a combo box based on your drop down information, and via the xl dialog box open you can select multiple workbooks to open and then apply to each workbook. But the question I would ask do you want the Footer to go on every single worksheet in each book that you open?

So I would imagine open selected workbooks then each worksheet in the activeworkbook add footer (which side, left, centre or right) with the value selected from the drop down on a userform, then Save the activeworkbook and close it.

What happens if the workbook already has a footer?

What needs to be in the drop down selection, data from a cell or written contents you add in the code side?

If you can supply answers then the code can be created.
 
Upvote 0
Thank you Trevor for taking time to answer my query. My answers are as follows:


You can use a userform to add a combo box based on your drop down information, and via the xl dialog box open you can select multiple workbooks to open and then apply to each workbook. But the question I would ask do you want the Footer to go on every single worksheet in each book that you open? - Im afraid I need to have the footer in every worksheet of each workbook that I shall choose.


So I would imagine open selected workbooks then each worksheet in the activeworkbook add footer (which side, left, centre or right) with the value selected from the drop down on a userform, then Save the activeworkbook and close it. Correct..It should be centre, and the activeworkbooks need to be saved and closed.


What happens if the workbook already has a footer?

Would it be possible to append the footers that I require? If not then we have to delete the old footers.


What needs to be in the drop down selection, data from a cell or written contents you add in the code side?

It should be data from a cell.

If you can supply answers then the code can be created.
 
Upvote 0
I have created a userform in VBA and added 3 features, 1 Combo box and named it cboNames. 2 Command Buttons.

Code behind each feature is as follows:

Behind the form when it is shown, called Initialize, it fills the drop down from data on sheet 2, cahange to your sheet name.

Code:
Private Sub UserForm_Initialize()
Sheets("[COLOR=red]Sheet2[/COLOR]").Select
Range("B2").Select
    Do Until ActiveCell.Value = ""
        Me.cboNames.AddItem ActiveCell.Value
    ActiveCell.Offset(1, 0).Select
    Loop
    

End Sub

Code behind first button to show Open dialogue box, make sure you select from the drop down before clicking the button.

Code:
Private Sub cmdOpen_Click()
Application.Dialogs(xlDialogOpen).Show
End Sub

Next Command button to run code, this will run on the first open book and add the footer to each sheet, as you mentioned you might need to change the drop down, before you click the command button again to run on the next workbook, and so on.

Code:
Private Sub cmdAddFooter_Click()
Dim wksht As Worksheet
For Each wksht In Worksheets
    wksht.PageSetup.CenterFooter = Me.cboNames.Value
    
Next wksht
ActiveWorkbook.Save
ActiveWorkbook.Close

End Sub

I hope it helps you out.
 
Upvote 0

Forum statistics

Threads
1,224,520
Messages
6,179,270
Members
452,902
Latest member
Knuddeluff

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