VBA Copy contents of leftheader into cell(s)

bosco2

New Member
Joined
Jan 15, 2015
Messages
14
I am trying to copy the contents (actual words, no formatting information) into cells on a worksheet.

I currently assign the leftheader to a variable:
leftheader = OpenBook.Sheets("sheet1").PageSetup.leftheader

But when I assign it to a cell
ThisWorkbook.Worksheets("Sheet2").Range("A1") = leftheader

It puts all the information into one cell including the format/font information (i.e. &"Trebuchet MS,Regular"&G)

Is there a way to paste it into a cell the same way if I just copied/pasted manually the header content. (it has an address so I would expect it to paste into multiple cells). The caveat is that I am copying the leftheader information from worksheet 1 and pasting it into cell in worksheet 2.

Thank you.

Also asked here VBA Copy content of LeftHeader into cells
 
Last edited by a moderator:

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
I suspedt you will have to use some worksheet funtions to like LEFT() and MID() to pare the LeftHeader down to only the text. Something like
VBA Code:
txt = Sheet2.PageSetUp.LeftHeader
Sheet2.Range("A1") = Mid((txt, 2, InStrRev(txt, "&") -3)
 
Upvote 0

Forum statistics

Threads
1,214,431
Messages
6,119,457
Members
448,898
Latest member
drewmorgan128

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