Insert cell value into footer

nuficek

Board Regular
Joined
Jul 20, 2016
Messages
54
Office Version
  1. 365
Platform
  1. Windows
Could anybody help me please why my code to insert cell value to the footer doesn't work?

VBA Code:
Private Sub Workbook_BeforePrint(Cancel As Boolean)

Dim ws1 As Worksheet: Set ws1 = ThisWorkbook.Sheets("Sheet1")
Dim ws2 As Worksheet: Set ws2 = ThisWorkbook.Sheets("Sheet2")

            ws2.PageSetup.LeftFooter = format(ws1.Range("M3").Value, "dd-mmm-yyyy")
End Sub
 
Also describe how you are putting the code in the ThisWorkbook module.
 
Upvote 0

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
WorkBook_module.jpg
 
Upvote 0
Because it isn't working when you are using the print options, it is working when you change cells and firing every time you change cells.

I asked about the sub name because the word format in the code should read as Format i.e. with a capital F and so it is working out why it isn't capitalizing as that is probably the same reason for your issue.

Have you used the name Format when declaring any variables?
 
Upvote 0
Because it isn't working when you are using the print options, it is working when you change cells and firing every time you change cells.

I asked about the sub name because the word format in the code should read as Format i.e. with a capital F and so it is working out why it isn't capitalizing as that is probably the same reason for your issue.

Have you used the name Format when declaring any variables?
You are right, I'm using Date picker code programmed by The FrankensTeam. And the "Format" is used there. So how can I fix that?
 
Upvote 0
Rename the variable and everywhere that it appears in the code.
 
Upvote 0
Rename the variable and everywhere that it appears in the code.
I was worried about your answer :) It would be too much work so keep it under worksheet_change. But it's good to know it to avoid problems in the future problems.
Anyway, thanks a lot for your help ;)
 
Upvote 0
@MARK858
Rich (BB code):
Rename the variable and everywhere that it appears in the code.
Dang, that's a good pickup Mark...... (y) (y)
 
Upvote 0
Anyway, thanks a lot for your help ;)
Your welcome
Dang, that's a good pickup Mark...... (y) (y)
Michael, I was a bit suspicious when I first read the code and saw the f wasn't capitalised but at the time I was thinking that the OP had retyped it in the thread. A bit surprised that it was code by The FrankensTeam at it is a bit sloppy for them.
 
Upvote 0

Forum statistics

Threads
1,214,429
Messages
6,119,433
Members
448,897
Latest member
ksjohnson1970

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