Macro is exporting entire workbook as PDF instead of selected sheets

jondavis1987

Active Member
Joined
Dec 31, 2015
Messages
443
Office Version
  1. 2019
Platform
  1. Windows
I am trying to export the sheet named A and the sheet named Sheet2. The below code is part of a big macro that i'm using. When i use the macro it exports the entire workbook as a pdf.

VBA Code:
        fName = srcWB.Sheets("A").Range("A!F19").Value
        

Dim FolderPath As String

FolderPath = "C:\Users\jdavis\Dropbox\Quality Control\Asphalt\Asphalt Reports\"


       
    Sheets(Array("A", "Sheet2")).Select
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=FolderPath & fName, _
        openafterpublish:=True, ignoreprintareas:=False

    End With
   
       End If
       
End Sub
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
I can't figure out why it's not working on these specific sheets. It works on the other two sheets in a different macro. Made me think something was off in the name so i triple checked that. I ended up just making the other sheets hidden early in the macro and then being visible after it exports as a PDF
 
Upvote 0

Forum statistics

Threads
1,214,929
Messages
6,122,315
Members
449,081
Latest member
tanurai

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