Add Date in Header Using Macros:
In this post, we are going to see how to Add Date in Header Using Macros (VBA) in Excel Office 365 with the best example. Let’s jump into this article!! Get an official version of MS Excel from the following link: https://www.microsoft.com/en-in/microsoft-365/excel
Add Date in Header Using Macros:
- On the Developer Tab, select the Visual Basic option under the Code section.
- You have to activate the sheet where you want to add a date in the header in Excel.
- Now, enter the below code.
VBA code for Add date in header using Macros in Excel
Sub AddDateInHeader()
‘Here, we used the center header to show the date
With ActiveSheet.PageSetup
.LeftHeader = ” “
.CenterHeader = “&D”
.RightHeader = ” “
End With
ActiveWindow.View = xlNormalView
End Sub
- From the above code, “&D” represents the date value and *“LeftHeader, CenterHeader, RightHeader” * represents the position of the date in the header section of the sheet.
- You need to save the code by selecting it. Then close the window.
- You have to open the sheet containing the data. On the Developer Tab, choose the Macros option in the Code section.
- You have to make sure that your macro is selected and click the Run button.
- Now, the date will be added to the header.
- If you want to check whether it is added or not, go to the File Tab, select the *Print * option.
- Now, you can see that the date is added in the header of the spreadsheet as shown in the below screenshot.
Closure:
In the above article, you can understand the steps to Add Date in Header Using Macros (VBA) in Excel Office 365 with the best example. Leave your feedback in the comment section. Thanks for visiting Geek Excel. Keep Learning!!
Top comments (0)