DEV Community

Andrews
Andrews

Posted on • Originally published at geekexcel.com on

How to Add Custom Footer Using Macros (VBA) in Excel Office 365?

Add Custom Footer Using Macros in Excel:

Here, we come up with the steps to Add Custom Footer Using Macros in Excel Office 365 with an example. Get an official version of MS Excel from the following link: https://www.microsoft.com/en-in/microsoft-365/excel

Steps to Add Custom Footer Using Macros:

Follow the below steps to add a custom footer using macros in the spreadsheet.

  • Go to the Developer Tab, select the Visual Basic option under the Code section.

Select Visual Basic option
Select Visual Basic option

  • You need to activate the sheet where you want to add a custom footer.
  • Kindly, enter the below code.

VBA code for Add custom footer using Macros in Excel

Sub AddCustomFooter()

Dim inputText As String inputText = InputBox(“Enter your text for the custom footer”, “Custom Footer”)

‘Add your custom text to the right footer

With ActiveSheet.PageSetup

.LeftFooter = ” “

.CenterFooter = ” “

.RightFooter = inputText

End With

End Sub

  • You need to save the code by selecting it. Then close the window.

Enter the Source Code
Enter the Source Code

  • You need to open the sheet containing the data. On the Developer Tab, choose the Macros option in the Code section.

Choose the Macros option
Choose the Macros option

  • You need to make sure that your macro is selected and click the Run button.

Macro dialog box
Macro dialog box

  • Now, the custom Footer dialog box will open and you need to enter the text in the text box. Then, click the OK button.

Custom Footer Dialoh Box
Custom Footer Dialog Box

  • Now, the specified text will be added to the footer of the spreadsheet.
  • If you want to check whether it is added or not, go to the File Tab, select the *Print * option.

Choose the File Tab
Choose the File Tab

  • Now, you can see the result in the print preview window as shown in the below screenshot.

Result
Result

Verdict:

In the above article, you can clearly understand the steps to Add Custom Footer Using Macros in Excel Office 365 with an example. Drop your feedback in the comment section. Thanks for visiting Geek Excel. Keep Learning!!

See Also:

Top comments (0)