Inserting a Range into Footer

Ornithopter

New Member
Joined
Jul 5, 2004
Messages
32
I'm wondering if there is any way to insert a Range of cells into the
footer. The effect I'm looking for is the same as if you were to go
to 'Page Setup'>Sheet>'Rows to Repeat at Top' except I want
'Rows to Repeat at Bottom'.

I have tried the following with no luck:

Code:
Private Sub Workbook_BeforePrint(Cancel As Boolean)

    With ActiveSheet.PageSetup
        .LeftFooter = Range("B237:M239").Text
    End With

End Sub

Where the range "B237:M239" contains the information
and formatting that I would like at the bottom of every
page.

Any ideas?
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Hi Ornithopter,

Your approach is correct and should work, but you cannot assign the text of a range of multiple cells to a single text string--you must do it one cell at a time, like this:

.LeftFooter = [B237].Text & [C237].Text & ... & [M239].Text

This basically concatenates all the cell text to produce the desired string.

This may not completely produce the desired result, though, if you are expecting a carriage return and linefeed between the text contained in different rows of cells. In order to add line feeds you must concatenate vbLF (or perhaps vbCrLf) into the string where you want the new line to occur.
 
Upvote 0
Hmmm....

Thanks Damon.

It is unfortunate that there is no way to maintian
the formatting of the cells as they have borders
and pictures that I would like to include at the
bottom of every page.

I guess that it would be best to import the
printable area into Word and do it from there?
 
Upvote 0
Another Solution I just thought of (to stay in excel)
would be to have 2 sheets:
one with data, the other with the footer.

Then write a macro that:
1) Calculates how many rows fit on
the current page settings.

2) Calculates how many rows the footer
range requires.

3) Removes all 'Old' footers (if I ran the
macro before)

4) Inserts a copy of the footer at regular
calculated intervals so that it appears
at the bottom of every page and gives
the effect I want.

Thoughts?
 
Upvote 0
Hi again Ornithopter,

Yes, if I understand you correctly the method you outline should work. The problem with using standard headers/footers is that they only accept text, not graphics--and what I believe you want is to paste a picture of the block of cells into the footer. Definitely this could be done with Word, which does support graphics in headers and footers. But of course, as you describe, you can also "simulate" headers and footers by simply placing the text and graphics in the appropriate places in your spreadsheet, and sizing the real header and footer to essentially zero height to make room. This is probably easier than using the Word approach.

My first thought about how to do this would be to create a block of rows on the second worksheet that contains the desired footer (or header). Then your code would do a copy and paste to put those rows into the first worksheet at the desired row locations. Rather than counting rows to determine the paste location, a better method would be to look for a row that contains the PageBreak (see the PageBreak property in the VBA helps) so that you will insert the header/footer in the correct place regardless of the height formatting of the rows. If you want the footer to appear at exactly the same position on each page (height-wise) you will need to do a bit of arithmetic to determine what to set the height of the first (top) pasted row to.
 
Upvote 0

Forum statistics

Threads
1,215,214
Messages
6,123,664
Members
449,114
Latest member
aides

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