Save excel worksheet to pdf and use more then one cells name

bixha

New member
Joined
Oct 23, 2015
Messages
8
Reaction score
0
Points
0
Location
Ferizaj, Kosovo
Excel Version(s)
excel 2010
I am attempting to write a macro to save a worksheet to PDF and name it based on a cell value,B10, K10 and K11 however I am getting an "expected end of statement error with my code when I trying to add more cells this Code is working only for this cell B10


Code:
[COLOR=#333333]Sub PDF()[/COLOR]
[COLOR=#333333]Dim SaveAsStr As String[/COLOR]

[COLOR=#333333]SaveAsStr = ActiveWorkbook.Path & "\" & ActiveSheet.Range("B10").Value [/COLOR]

[COLOR=#333333]ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _[/COLOR]
[COLOR=#333333]Filename:=SaveAsStr & ".pdf", _[/COLOR]
[COLOR=#333333]OpenAfterPublish:=False[/COLOR]
[COLOR=#333333]End Sub[/COLOR]
 
What sort of information do you have in these cells ?
This would work:
SaveAsStr = ActiveWorkbook.Path & "\" & ActiveSheet.Range("B10").Value & ActiveSheet.Range("K10").Value & ActiveSheet.Range("K11").Value
 
Last edited:
Back
Top