Macro To Print In Excel

Microsoft Excel 2007
July 30, 2011 at 08:02:49
Specs: Windows 7
Hi Every one ,

Am facing a problem using macros in excel.

I've created a button to print my sheets and it worked, but my problem is , am trying to print the header wich is a logo in the first page only, and i dont want it to appear in the second and the third page,
please help me i will paste my code here which i want to add the hader which is a logo in the first page only to it.


Private Sub print()

Dim n As Integer

With Worksheets("maramsheet")
'set print area and print parameters
With .PageSetup
.PrintArea = "B1:J125"
.Orientation = xlPortrait
.LeftMargin = Application.InchesToPoints(0.88)
.RightMargin = Application.InchesToPoints(0.88)
.TopMargin = Application.InchesToPoints(0.75)
.BottomMargin = Application.InchesToPoints(0.5)
.HeaderMargin = Application.InchesToPoints(0.31496062992126)
.FooterMargin = Application.InchesToPoints(0.1)
.CenterHorizontally = True
.CenterVertically = True
.Draft = False
.PaperSize = xlPaperLetter
.FitToPagesWide = 1
.FitToPagesTall = 1

End With
'loop through all records 1 to 2
For n = 1 To 1
'change value in L9 drop-down
.Range("K1") = n
'print each record on named printer
Next n

End With
End Sub

please help me

See More: Macro To Print In Excel

Report •

July 30, 2011 at 12:49:23
Look here:

The code samples are mainly for Footers, but as the text says, they should work for headers also.

Basically you need to save the Header in a variable, print the the first page with the header, then set the Header to nothing ("") for the rest of the pages and then use the variable to reinstate the Header for the next time you print.

Good luck!

Click Here Before Posting Data or VBA Code ---> How To Post Data or Code.

Report •

July 31, 2011 at 01:04:43
hello mr. Derby,

i tried this code before, but it didnot work for me.

please help me



Report •

July 31, 2011 at 03:39:05
What do you mean "it did not work for me"?

Since we can't see your workbook from where we're sitting, simply saying that "it did not work" doesn't really help us troubleshoot your problem.

What didn't work? Did it give you an error? Did it not print the header on the first page? Did it print the header on every page? What didn't work?

Click Here Before Posting Data or VBA Code ---> How To Post Data or Code.

Report •

Related Solutions

August 2, 2011 at 06:58:32
I Mean it prints the haeder in all the sheets ...

thank you mr.derby

Report •

Ask Question