[Solved] VBA: Save as filename

  • Hi guys
    I'm trying to use the code below to add the invoice number and supplier code to the file name - can't get it to work: what am I doing wrong?

    ActiveWorkbook.SaveAs FileName:=Range("PO_No")&("Supplier_Code").Value

    Any suggestions gratefully received. I've managed to get everything else to work from this fantastic forum.
    many thanks

  • Thanks very much Andy - works great now - however, the invoice number is 0007, but only the 7 appears in the filename. is there anyway of getting the 3 0's to appear too?


  • Can't get your code to work. This is what I have so far...

    Sub Button11_click()
    ActiveWorkbook.SaveAs FileName:=Range("PO_No").Value & Range("Supplier_Code").Value & Range("Issue_date").Value

    End Sub

  • Try this

    ActiveWorkbook.SaveAs FileName:=Format$(Range("PO_No").value ,"0000") & Range("Supplier_Code").Value & Range("Issue_date").Value

    Hope this helps.


    Barrie Davidson
    My Excel Web Page
    "You're only given a little spark of madness. You mustn't lose it." - Robin Williams

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!