Results 1 to 9 of 9

PrintSelectionToPDF - Select an area in sheet based on "Selected" - divided into 2 pages

Threaded View

  1. #1
    Registered User
    Join Date
    09-02-2021
    Location
    Denmark
    MS-Off Ver
    365
    Posts
    4

    PrintSelectionToPDF - Select an area in sheet based on "Selected" - divided into 2 pages

    I have written this, but have a problem that if one of the ranges are "False", then the print is divided into two printed pages. Can anyone see what the problem is?

    Sub PrintSelectionToPDF()
    Dim UruruSelected As Boolean, PerferaSelected As Boolean, StylishSelected As Boolean, EmuraSelected As Boolean, GulvSelected As Boolean
    If Sheets("Indtast her").Range("F5").Value = "Ja" Then UruruSelected = True
    If Sheets("Indtast her").Range("F9").Value = "Ja" Then PerferaSelected = True
    If Sheets("Indtast her").Range("F13").Value = "Ja" Then StylishSelected = True
    If Sheets("Indtast her").Range("F17").Value = "Ja" Then EmuraSelected = True
    If Sheets("Indtast her").Range("F21").Value = "Ja" Then GulvSelected = True
    Sheets("Prislisteudvalg").Select
    Dim Headline As Range, Ururu As Range, Perfera As Range, Stylish As Range, Emura As Range, Gulv As Range, Bund As Range
    Dim pdfile As String
    'Setting range to be printed
    Set Headline = Range("A1:I3")
    Set Ururu = Range("A4:I7")
    Set Perfera = Range("A8:I11")
    Set Stylish = Range("A12:I15")
    Set Emura = Range("A16:I19")
    Set Gulv = Range("A20:I23")
    Set Bund = Range("A24:I36") '
    'Set myMultipleRange = Union(Headline, Ururu, Perfera, Stylish, Emura, Gulv, Bund)
    Set myMultipleRange = Headline
    If UruruSelected Then
    Set myMultipleRange = Union(myMultipleRange, Ururu)
    End If
    If PerferaSelected Then
    Set myMultipleRange = Union(myMultipleRange, Perfera)
    End If
    If StylishSelected Then
    Set myMultipleRange = Union(myMultipleRange, Stylish)
    End If
    If EmuraSelected Then
    Set myMultipleRange = Union(myMultipleRange, Emura)
    End If
    If GulvSelected Then
    Set myMultipleRange = Union(myMultipleRange, Gulv)
    End If
    Set myMultipleRange = Union(myMultipleRange, Bund)
    'setting file name with a time stamp.
    pdfile = "Prisliste" & "_" & Format(Now(), "yyyymmdd_hhmmss") & ".pdf"
    'setting the fulli qualified name. The resultent pdf will be saved where the main file exists.
    pdfile = ThisWorkbook.Path & strfile
    myMultipleRange.ExportAsFixedFormat Type:=xlTypePDF, _
    Filename:=pdfile, _
    Quality:=xlQualityStandard, _
    IncludeDocProperties:=True, _
    IgnorePrintAreas:=False, _
    OpenAfterPublish:=True
    End Sub
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Formula to add a "yes" or "no" based on checkboxes being selected?
    By Gootz in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 04-30-2017, 12:44 PM
  2. [SOLVED] Column X-Ref list - Sheet1 Col A "pages", Col B:FL "Req" to Sheet2 ColA "req", ColB "page"
    By excel-card-pulled in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 04-07-2017, 09:30 AM
  3. Replies: 1
    Last Post: 07-16-2016, 09:20 PM
  4. [SOLVED] Code that copies row of data to another sheet based on text "Complete"/"Delete"
    By Dremzy in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 04-20-2014, 05:51 PM
  5. Modify code to email a selected range or ("print area") in lieu of ActiveSheet
    By robertse in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 06-15-2010, 05:15 PM
  6. Remove all "to " from selected area
    By wali in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-27-2010, 09:10 AM
  7. Questionnaire sheet: Select "yes" or "no," and only one can be selected
    By bpatterson in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-13-2006, 06:10 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