Simple macro Excel 2010

%3CLINGO-SUB%20id%3D%22lingo-sub-1563142%22%20slang%3D%22en-US%22%3ESimple%20macro%20Excel%202010%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1563142%22%20slang%3D%22en-US%22%3E%3CP%3EHello.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI'm%20trying%20to%20execute%20a%20simple%20macro%20to%20print%20information%20on%20the%20footer%20of%20actice%20sheet%20using%20Excel%202010.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWhen%20I%20record%20a%20macro%20personalizing%20the%20footer%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ELeft%20footer%20-%26gt%3B%20Page%3A%20%26amp%3B%5BPage%5D%20of%26nbsp%3B%26amp%3B%5BPages%5D%3C%2FP%3E%3CP%3ERight%20footer%20-%26gt%3B%26nbsp%3B%26amp%3B%5BDate%5D%20-%26nbsp%3B%26amp%3B%5BHour%5D%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAfter%202nd%20running%20of%20macro%20the%20footer%20is%20not%20completed%20and%20the%20print%20out%20info%20is%20not%20complete%2C%20like%3A%3C%2FP%3E%3CP%3ELeft%20footer%20-%26gt%3B%20Page%3A%20%26amp%3B%3C%2FP%3E%3CP%3ERight%20footer%20-%26gt%3B%26nbsp%3B%26amp%3B%5BDate%5D%20-%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIs%20it%20related%20to%20specific%20setup%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1563142%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%20Desktop%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1563198%22%20slang%3D%22de-DE%22%3ESubject%3A%20Simple%20macro%20Excel%202010%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1563198%22%20slang%3D%22de-DE%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F748143%22%20target%3D%22_blank%22%3E%40rickrpr%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22tlid-translation%20translation%22%3E%3CSPAN%20class%3D%22%22%3EDo%20it%20yourself%20quickly%20with%20VBA%20header%20and%20footer.%3C%2FSPAN%3E%20%3CSPAN%3ESimply%20in%20one%20module%20and%20adjust%20as%20needed.%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3EOption%20Explicit%0A%0ASub%20Set_Print_Header_footer%20()%0AWith%20ActiveSheet.PageSetup%0A'.PrintArea%20%3D%20%22A1%3AF60%22%20'Area%201%0A'.PrintArea%20%3D%20%22CS1%3ADG60%22%20'Area%202%0AActiveSheet.PageSetup.PrintArea%20%3D%20%22G1%3AU60%22%0A%0AActiveSheet.PageSetup.CenterHeader%20%3D%20%22%26amp%3B%22%22Arial%2CFett%22%22%22%20%26amp%3B%20%22%26amp%3B14%22%20%26amp%3B%20%22BEST_Sheet_Header%22%20%26amp%3B%20%22%20-%20%22%20%26amp%3B%20Format(Range(%22E4%22).Value%2C%20%22mmmm%20yyyy%20%22)%0AActiveSheet.PageSetup.LeftHeader%20%3D%20%22%26amp%3B%22%22Arial%2CFett%22%22%22%20%26amp%3B%20%22%26amp%3B14%22%20%26amp%3B%20%22My%20Company%22%20%26amp%3B%20Chr(10)%20%26amp%3B%20Range(%22A3%22)%20%26amp%3B%20Chr(10)%20%26amp%3B%20Range(%22F4%22)%0AActiveSheet.PageSetup.LeftFooter%20%3D%20%22%26amp%3B%22%22Arial%2CFett%22%22%22%20%26amp%3B%20%22%26amp%3B10%22%20%26amp%3B%20%22Call%20me..my%20phone%20is%E2%80%A6%22%0A'etc......%0AEnd%20With%0AApplication.CommandBars.ExecuteMso%20%22PrintPreviewAndPrint%22%0AEnd%20Sub%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20you%20find%20this%20helpful%2C%20please%20mark%20it%20as%20%22Best%20Answer%22%20and%20as%20Like%20(click%20thumbs%20up)%2C%20it%20will%20be%20beneficial%20to%20more%20community%20members%20reading%20here.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ENikolino%3C%2FP%3E%3CP%3EI%20know%20I%20don't%20know%20anything%20(Socrates)%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Visitor

Hello.

 

I'm trying to execute a simple macro to print information on the footer of actice sheet using Excel 2010.

 

When I record a macro personalizing the footer:

 

Left footer -> Page: &[Page] of &[Pages]

Right footer -> &[Date] - &[Hour]

 

After 2nd running of macro the footer is not completed and the print out info is not complete, like:

Left footer -> Page: &

Right footer -> &[Date] -

 

Is it related to specific setup?

 

Thanks!

 

1 Reply

@rickrpr 

Do it yourself quickly with VBA header and footer. Simply in one module and adjust as needed.

 

Option Explicit

Sub Set_Print_Header_footer ()
With ActiveSheet.PageSetup
'.PrintArea = "A1:F60" 'Area 1
'.PrintArea = "CS1:DG60" 'Area 2
ActiveSheet.PageSetup.PrintArea = "G1:U60"

ActiveSheet.PageSetup.CenterHeader = "&""Arial,Fett""" & "&14" & "BEST_Sheet_Header" & " - " & Format(Range("E4").Value, "mmmm yyyy ")
ActiveSheet.PageSetup.LeftHeader = "&""Arial,Fett""" & "&14" & "My Company" & Chr(10) & Range("A3") & Chr(10) & Range("F4")
ActiveSheet.PageSetup.LeftFooter = "&""Arial,Fett""" & "&10" & "Call me..my phone is…"
'etc......
End With
Application.CommandBars.ExecuteMso "PrintPreviewAndPrint"
End Sub

 

If you find this helpful, please mark it as "Best Answer" and as Like (click thumbs up), it will be beneficial to more Community members reading here.

 

Nikolino

I know I don't know anything (Socrates)