I want to dynamically set some data to the header (and/or footer) of a sheet.
From several forums I found numerous examples showing how to do that, and they all seem pretty easy to understand without any difficulty.
So I applied what I read to a simple try like this:
Private Sub Workbook_BeforePrint(Cancel As Boolean)
ActiveSheet.PageSetup.CenterFooter = Range("A1")
End Sub
But it merely don't work: nothing appears in my sheet preview.
BTW the only ambiguous point in documentations was about the expression of the data to use, so I also tried replacing Range("A1")
by Range("A1").Text
, then by Range("A1").Value
, also without success.
I suppose I'm missing some simple point...
As other answers already suggested, the code was fine and the problem wasn't there: in fact, the issue came from the fact that it was not invoked.
And this in turn came from a silly situation: the Design Mode was enabled!
With Design Mode disabled, all works fine...