VBA for a 'Print All to PDF' Button?

shadowsinner

New Member
Joined
Dec 15, 2018
Messages
1
Hi all,

I'm not sure if this could be done, but does anyone know how to use a macro function to make a Print All to PDF button that is on a VLOOKUP worksheet?

I have a workbook with my grade level's student data, with each class separated onto different worksheets. One of the last worksheets is a display of all students' data pulled out of the individual class's worksheets. The very last worksheet is a formatted page that pulls data via VLOOKUP from the total student body's worksheet that allows you to view individual students' results one by one.

Currently on that last worksheet is a Print All button linked to a macro PrintAll function that allows me to print all the students' data individually, page by page. However, in an effort to save paper, I would like to have the function converted to a 'Print All to PDF' function, rather than just a Print All.

Is this possible?

Currently, this is what I'm using for the PrintAll function:

Sub PrintAll()


Dim copynumber As Long


For copynumber = 1 To 97
With ActiveSheet
.Range("M8").Value = copynumber
.PrintOut
End With
Next copynumber
End Sub


Does this make sense to anyone? Is this even possible in Excel? Your help is greatly appreciated.

Thank you for your help.


https://drive.google.com/open?id=1QB-6ganLr2uoexwhGT34cMoO9Ji-II67 <-- this is a screenshot of my last formatted sheet for the PrintAll function.
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Possibly something like this

Code:
Sub PrintAll()

    Dim copynumber As Long
    Dim PDFName As String, Path As String

    For copynumber = 1 To 97
        With ActiveSheet
            .Range("M8").Value = copynumber
            
            Path = CurDir
            PDFName = Path & "\StudentData" & copynumber & ".pdf"
            .ExportAsFixedFormat Type:=xlTypePDF, Filename:=PDFName
        End With
    Next copynumber
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,246
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top