Return to site

How to set print area in excel

broken image

LeftMargin = Application.InchesToPoints(0.75) Range(Selection, ActiveCell.SpecialCells(xlLastCell)).SelectĪ = '$A$1: $F$429' Is there a way to use a variable in place of $F$429 so that the print area is automatically set to print all active rows that contain data? Here is my current macro: When I run the macro on a larger workbook, the print area ends on row 429 and nothing past that prints. The macro seems to hardcode the “LastCell” value of the workbook (in this case F429). How can I automatically set the print area in a macro? I recorded a macro that saved the workbook, selected the cells that contained data (by selecting cell A1, then pressing Ctrl-End to go to the “LastCell”), set the print area, then sets “Fit All Columns on One Page”.

broken image