Date and reference number being inserted into footer after the first page

dpaton05

Well-known Member
Joined
Aug 14, 2018
Messages
2,352
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
How do I put things into the footer on all pages after the first using vba?
 
Last edited:
VBA Code:
RAnge("H" & lr+2).formula="=Sum("H1:H" & lr) / 2"
 
Upvote 0

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Thanks for all the help Michael, I have got it to work with this code, just needed a few ideas of the syntax to use :)

VBA Code:
    Dim lr As Long
    lr = Cells(Rows.Count, "H").End(xlUp).Row
Dim cell As Range, s As Long, c As Long, curr As Currency

s = 1
c = 0
For Each cell In Range("H1:H" & lr)
    If cell.Offset(0, -2).Value = "Total incl. GST" Then
        'With r
         c = cell.Value + c
            '.Formula = "=sum(r" & s & "c:r" & r.Row - 1 & "c)"
       ' End With
    End If
Next cell
curr = c
With ActiveSheet.PageSetup
    .DifferentFirstPageHeaderFooter = True
    .FirstPage.CenterFooter.Text = ""
    'This inserts the date in the left footer
    .LeftFooter = Format(Now(), "mmmm d, yyyy")
    'This inserts the reference number and the total price in the footer at the centre, one of top of the other.
    .CenterFooter = ref3 & " " & Chr(10) & curr

End With

The number that is put in the footer is a straight number. How do I give it the currency format?
 
Upvote 0
Change this
VBA Code:
curr = c
To
VBA Code:
curr = Format(c, "Currency")
 
Upvote 0
Is there a way to have the $ in front and comas after each three numbers?
 
Upvote 0
I have also just noticed, after the above code is run, all of the formulas in the total cells, H33, H66 etc, get changed to be absolute references of the being the sum of every cell above the cell in column H. I remember I originally coded this in somewhere as that is what I originally wanted but now i just want each of the total cells to be the sum of the two cells above it. In the first case, that would be H31:H32
 
Upvote 0
Rich (BB code):
Is there a way to have the $ in front and comas after each three numbers?
Umm, that's what the code does !
 
Upvote 0
The code puts the number in the right spot but it doesn't have a dollar sign in the front of it and doesn't use any commas either.
 
Upvote 0
Did you clear the footer first ?
It works fine for me !
How is the cell formatted that provides the value ??
 
Upvote 0

Forum statistics

Threads
1,215,598
Messages
6,125,748
Members
449,258
Latest member
hdfarid

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