Results 1 to 17 of 17

Unique Print to PDF Challenge

Threaded View

  1. #1
    Registered User
    Join Date
    08-24-2017
    Location
    phoenix, az
    MS-Off Ver
    2010
    Posts
    9

    Unique Print to PDF Challenge

    Good day all,

    I have an Excel workbook with various sheets inside, each of these sheets must be converted to a PDF in sequential order. i.e. Lab 1, Lab 2, Lab 3, Lab 4, etc.
    The issue I run into sees my macro run, however it only creates one PDF file and it doesn't number the report (Lab 1, Lab 2, etc.) as I had hoped. I'm hoping someone here can show me the error I'm missing. The code is below, however I've changed some of the file destination information to make it generic looking. Please forgive my ignorance, I'm still relatively new to this whole VBA thing.
    (Also, please forgive me for not uploading the workbook, it's on a government server and they're not too happy to see proprietary information uploaded to the web.) Thank you in advance!

    Sub Printpdf()
    '
    ' Printpdf Macro
    '
    ' Keyboard Shortcut: Ctrl+p
    '
    Dim num As Integer
    Dim x As Integer
    
    
    
    For num = 1 To 4
    
    ' Here I actually have 130 (not 4) laboratories which need to have their individual results saved and converted to PDF
    
        Sheets("Indv Rep").Select
        Range("A2:k63").Select
    
        x = num
        Selection.Replace what:="$" & num, Replacement:="$" & num + 1, LookAt:=xlPart, _
                Searchorder:=xlByRows, MatchCase:=False
                
        If Range("B7").Value <> 0 Or Range("B22").Value <> 0 Or Range("B39").Value <> 0 Then
                             
       Sheets(Array("indv rep", "chart1", "chart2")).Select
       ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
          "M:\Folder 1\Folder 2\Folder 3\Folder 4\Folder 5\Lab " & Worksheets("Indv Rep").Range("A2").Value & ".pdf", OpenAfterPublish:=False
    
    ' Again, I would like to name each PDF sequentially. Like "Lab 1", "Lab 2" etc. through "Lab 130"
    
    End If
        
    Next num
    
    Selection.Replace what:="$" & x + 1, Replacement:="$2", LookAt:=xlPart, _
            Searchorder:=xlByRows, MatchCase:=False
      
    
    End Sub
    Last edited by shawnpatrick; 10-04-2019 at 03:51 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Select a unique value from a list and print the workbook
    By judeprem in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-28-2016, 02:18 AM
  2. VBA. identify unique values, loop them, filter them in, set print area & print it
    By rain4u in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-09-2012, 09:56 PM
  3. Excel to print unique reference numbers
    By Vibu212 in forum Excel - New Users/Basics
    Replies: 5
    Last Post: 05-16-2011, 04:05 PM
  4. Print Challenge
    By rz6657 in forum Excel General
    Replies: 1
    Last Post: 09-21-2007, 07:37 AM
  5. how to print a page many times but add a unique reference on each
    By ms_540 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-06-2006, 02:45 PM
  6. Challenge: Unique Values via Formulas
    By Peter Bernadyne in forum Excel General
    Replies: 3
    Last Post: 03-27-2006, 01:18 PM
  7. Print unique values
    By omnibrown in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-12-2006, 08:45 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1