Results 1 to 3 of 3

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

  1. #1
    Seeker bixha's Avatar
    Join Date
    Oct 2015
    Location
    Ferizaj, Kosovo
    Posts
    8
    Articles
    0
    Excel Version
    excel 2010

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



    Register for a FREE account, and/
    or Log in to avoid these ads!

    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:
    Sub PDF()
    Dim SaveAsStr As String
    
    SaveAsStr = ActiveWorkbook.Path & "\" & ActiveSheet.Range("B10").Value 
    
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
    Filename:=SaveAsStr & ".pdf", _
    OpenAfterPublish:=False
    End Sub

  2. #2
    Acolyte rollis13's Avatar
    Join Date
    Feb 2013
    Location
    Cordenons
    Posts
    31
    Articles
    0
    Excel Version
    2016 64bit
    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 by rollis13; 2015-11-29 at 09:46 PM.

  3. #3
    Seeker AnalystCave's Avatar
    Join Date
    Dec 2015
    Location
    Poland
    Posts
    11
    Articles
    0
    Which row is throwing the error?

Posting Permissions

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