excel - Exporting Specific Range of Cells to PDF - VBA -


i trying save , export current sheet in excel pdf using vba. code working, pdf being published entire sheet (which includes couple hundred blank rows , columns past have text. @ link 1, there tutorial on how through "options" menu in save window. code me, , select range encompasses have text. worksheet being exported going used many create pdf's, changes in size of data in worksheet. explains reasoning wanting through code automatically file exported. great. thanks!

set print area, set print area a1 last cell in column "d"

sub set_printrnag()     dim lstrw long     dim rng range     lstrw = cells(rows.count, "d").end(xlup).row     set rng = range("a1:d" & lstrw)     activesheet.pagesetup.printarea = rng.address  end sub 

Comments