updating pagesetup using cells from master worksheet - orientation & formatting footer - excel vba


New Member
Feb 4, 2016

I am new to excel vba and trying to complete my 1st project. I have the following problems but if anyone has feedback on a better way of doing things - let me know.

I want to create a "master" or "driver" macro workbook. This workbook will contain a sheet (adHoc) that will contain instructions how to format another workbook. I am working on the page setup portion now and I am stuck on a couple of statements.

#1 I want to update the footer - cell b28 of my master worksheet contains this

"&9 2014 YTD Measure Data for PCP" & Chr(10) & " &D &T" & Chr(10) & " Version 1.0" & Chr(10) & " &F"

when I run the macro - I want the formatting to be applied to the text but the entire statement as is displayed - I don't want to see the &9 or quotes - How do I get the macro to apply the format codes?

#2 I get a popup box with "type mismatch" when I set the orientation. cell b36 contains the value xlLandscape If I use the statement .PageSetup.Orientation = xlLandscape it works fine - it just has a problem reading the value from b36.

Julie :eek:

Here is the code that I am using.

Sub pg_setup()

    Dim reportWB As Excel.Workbook
    Dim sheet As Excel.Worksheet
    'open report workbook - name of workbook is in cell b4
    Set reportWB = Workbooks.Open(Workbooks("macros.xlsm").Sheets("adHoc").Range("b4").Value)
    Dim leftFooter
    leftFooter = Workbooks("macros.xlsm").Sheets("adHoc").Range("b28").Value
    For Each sheet In reportWB.Sheets
      With sheet
         .PageSetup.leftFooter = leftFooter
         .PageSetup.Orientation = Workbooks("macros.xlsm").Sheets("adHoc").Range("b36").Value
      End With     
End Sub

Forum statistics

Latest member

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...