using 2 cells to name file in macro saveing to PDF

jamo84

New Member
Joined
Jan 11, 2018
Messages
1
I have been able to save to PDF using 1 cell to name the file but require 2 i want to use I7 and I6
Im unsure of the next step and surprised i got this far

Sub saveaspdf()
'
' saveaspdf Macro
'


'
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"C:\Users\scottnay\Desktop\Test\Quote" & Range("I6").Value & ".PDF", Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _
True
End Sub
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
It's not clear whether U want to combine I6 & I7 (or viceversa) into one file name....
Code:
Dim FileName As String
'combime I7 & I6
FileName = CStr(Range("I7").Value) & CStr(Range("I6").Value)
'****OR***
'combime I6 & I7
FileName = CStr(Range("I6").Value) & CStr(Range("I7").Value)

ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, FileName:= _
 "C:\Users\scottnay\Desktop\Test\Quote" & FileName & ".PDF", Quality:=xlQualityStandard, _
 IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=True

It seems more likely that U want to choose between I6 and I7...
Code:
Dim FileName As String
'Use either I6 or I7
If MsgBox(prompt:="Do You want I6 file? (No = I7)", Buttons:=vbYesNo, Title:="Select file") = vbYes Then
FileName = CStr(Range("I6").Value)
Else
FileName = CStr(Range("I7").Value)
End If
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, FileName:= _
 "C:\Users\scottnay\Desktop\Test\Quote" & FileName & ".PDF", Quality:=xlQualityStandard, _
 IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=True
U really should properly identify your ranges with the sheet name. For example...
Code:
Sheets("Sheet1").Range("I7").Value
HTH. Dave
 
Upvote 0

Forum statistics

Threads
1,215,181
Messages
6,123,513
Members
449,101
Latest member
mgro123

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