vba - Create Dynamic Excel Macro for printing to PDF -
vba - Create Dynamic Excel Macro for printing to PDF -
i have excel document couple hundred lines in it. document contains list of users info each user. each user can have multiple different rows of information.
i have been trying past couple hours create macro allows excel file sort users according name, take names , print them pdf document users name , date printed file name.
example:
so column name "user1" needs printed rows info own pdf document. same goes "user2" , "user3" , such forth.
i tried using "record macro" alternative excel more gave me ideas rather working solution. record macro though not much wanting do. if provide guidance or provide help appreciate it.
thank you
sub exportnamestopdf2() ' ' exportnamestopdf2 macro ' ' keyboard shortcut: ctrl+j ' activewindow.smallscroll down:=-36 rows("1:1").select selection.autofilter selection.autofilter activeworkbook.worksheets("document - copy").autofilter.sort.sortfields.clear activeworkbook.worksheets("document - copy").autofilter.sort.sortfields.add key:= _ range("b1"), sorton:=xlsortonvalues, order:=xlascending, dataoption:= _ xlsortnormal activeworkbook.worksheets("document - copy").autofilter.sort .header = xlyes .matchcase = false .orientation = xltoptobottom .sortmethod = xlpinyin .apply end rows("2:4").select selection.printout copies:=1, collate:=true end sub
i wouldn't utilize autofilter.
i sort user name, create loop "a" prints, , loop "b" within goes row-by-row , evaluates user name changes.
something like:
i = 2 lastrow = 0 firstrow = if cells(i, 1) <> cells(i + 1, 1) lastrow = end = + 1 while lastrow < rows(firstrow & ":" & lastrow).printout copies:=1, collate:=true while cells(i, 1) <> ""
this assumes user id in column 1 ("a").
but prints, guess? don't see macro saving file anywhere.
excel vba excel-vba office-2013
Comments
Post a Comment