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

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).

JLGWhiz

Well-known Member
Joined
Feb 7, 2012
Messages
12,979
Office Version
  1. 2013
Platform
  1. Windows
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)
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,151,967
Messages
5,767,370
Members
425,409
Latest member
Whatisanexcel

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
Top