excel - VBA Printing in Groups of 4 Rows -
i have pretty specific spreadsheet contains wages/bonuses of employees. each employee has 4 rows (salary / bonus / salary % delta / bonus % of salary). problem i'm having managers have employees cutoff if goes multiple pages switched fit 1 x 1 condensed. there way have macro print in groups of 4 rows? or perhaps make prints 4 rows each employee on same page (salary/bonus/salary % delta/bonus % of salary) thank in advance!
private sub commandbutton1_click() dim sel_manager string 'specify headers repeated @ top activesheet.pagesetup .printtitlerows = "$5:$10" .printtitlecolumns = "$b:$m" .orientation = xllandscape .zoom = false .fittopageswide = 1 .fittopagestall = 1 end 'manager selection through simple inputbox sel_manager = combobox1 'insert autofilter worksheet cells.select selection.autofilter 'select manager defined in inputbox activesheet.range("b10", range("m10").end(xldown)).autofilter field:=1, criteria1:=sel_manager 'select range printed , specify manager in filename activesheet.range("b10", range("m10").end(xldown)).select selection.exportasfixedformat type:=xltypepdf, filename:= _ sel_manager + ".pdf", quality:=xlqualitystandard, _ includedocproperties:=true, ignoreprintareas:=false, openafterpublish:=true activesheet.showalldata end sub
i think have better solution you. can split print area on pages, every x rows. take @ example, every page have 100 rows:
lastrow = sheets("raport").range("b" & rows.count).end(xlup).row sheets("raport").pagesetup.printarea = "$a$1:$g$" & lastrow t = 4 ' number of title rows r = 96 ' number of rows on 1 page (without title rows) npages = application.roundup((lastrow - 4) / 96, 0) 'npages gives number of pages. sheets("raport").resetallpagebreaks sheets("raport").vpagebreaks(1).dragoff direction:=xltoright, regionindex:=1 ' may not necessary data on error resume next if npages > 1 = 1 npages - 1 activesheet.hpagebreaks.add before:=activesheet.range("a" & 5 + * 96) set activesheet.hpagebreaks(i).location = range("a" & 5 + * 96) next else activesheet.hpagebreaks(1).dragoff direction:=xldown, regionindex:=1 end if on error goto 0
Comments
Post a Comment