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

EvaFrank

New Member
Joined
Feb 4, 2016
Messages
1
Hello,

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.


Code:
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     
    
    Next
    
End Sub
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying

Forum statistics

Threads
1,215,063
Messages
6,122,935
Members
449,094
Latest member
teemeren

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