Print code Examples

Note: In Excel for windows you can use this for testing .PrintOut preview:=True in the code examples to check out what will be send to the printer, but this is not working in Mac Excel. Also From:=1, To:=3 and Copies:=2 is not working in Mac Excel and will print the whole worksheet or just one copy, in the Oneliners section on the bottom of this page you see that there are more problems.

Note: check out also this page : Hide Data Print and Unhide with the BeforePrint event

Print visible 0r visible and Hidden worksheets

If you want to print a whole workbook you can use ThisWorkbook.PrintOut Or ActiveWorkbook.PrintOut in Excel for Windows but this will not print hidden Worksheets. And on the Mac it will only print the ActiveSheet so this is no option for printing the whole workbook in Mac Excel with VBA code. You can use this macro examples below to print what you want.

Print every Worksheet with a value In cell A1

With this macro you loop through every worksheet and if there Is a value in a certain cell it will add the sheet to the array and print it. You can also test a for a word like Sh.Range("A1").Value = "PrintMe"

Print the same worksheet ? time with the number in cell or Header or Footer

This example will print ? copies of the same sheet (It use a Input box to ask you how many)
It will copy the page number in cell A1 or in the Header or Footer.

The example below continue printing where It left off, such as today you enter 25 in the input box it print numbered pages 1-25 and the next time when you enter 10 in the input box it print 26-35.

Oneliners to print

There are a few problems with the code lines below in Mac Excel, read the comments below the code line.

Web design by Will Woodgate