The code below is provided to show what I need to do, but I find that I cannot successfully copy the contents of the Right Header to the clipboard with VBA no matter the method or how short or elaborate the code. Maybe it just can’t be done? I am trying to avoid using pop up boxes to capture data that users are already used to putting in the header.
Sub copyrightheader()
ActiveSheet.PageSetup.RightHeader.Copy
ActiveSheet.Range("J1").Select
ActiveSheet.Paste
End Sub
>Solution :
If you look here: https://learn.microsoft.com/en-us/office/vba/api/excel.pagesetup.rightheader
…you can see that PageSetup.RightHeader reurns a String value, so you can assign that directly to a cell:
with ActiveSheet
.Range("J1").Value = .PageSetup.RightHeader
end with