VBA code file for file save as

  • Hi All,


    Need your help in achieving following please.


    Save As file in same folder using value from L6 (Date), N2 (Revision No.) and A6 (Name of Section).
    Format will be 21.08.2018 (L6) – v2.0(N2) – ABC 546(A6).xlsm


    Apologies if it has been requested before but I could not find any specific reference. Any help in above will be appreciated.

  • this will do the trick removed . and replaced it with space as it hampers saving excel file format ;)


    Code
    ActiveWorkbook.SaveAs Replace(Range("L6").Value & "-" & Range("N2").Value & "-" & Range("A6").Value, ".", "") & ".xlsm", 52
  • this will do the trick removed . and replaced it with space as it hampers saving excel file format ;)


    Code
    ActiveWorkbook.SaveAs Replace(Range("L6").Value & "-" & Range("N2").Value & "-" & Range("A6").Value, ".", "") & ".xlsm", 52


    Hi Ashu,


    Thank you for feedback, I haven't had the chance until now to try this. Unfortunately following error is coming up,


    Run-Time Error - 1004. I have uploaded the screenshot as attachment.


    Many Thanks for your help.


    Regards,

  • you have to give the file a path hence its saving it in a unknown location, below code will save the file where you have saved your macro file.


    Code
    ActiveWorkbook.SaveAs thisworkbook.path & "\" & Replace(Range("L6").Value & "-" & Range("N2").Value & "-" & Range("A6").Value, ".", "") & ".xlsm", 52
  • you have to give the file a path hence its saving it in a unknown location, below code will save the file where you have saved your macro file.


    Code
    ActiveWorkbook.SaveAs thisworkbook.path & "\" & Replace(Range("L6").Value & "-" & Range("N2").Value & "-" & Range("A6").Value, ".", "") & ".xlsm", 52


    Thank you Ashu and again very sorry for late reply as I had not tried it until today.


    It worked great, did some further tinkering to customise it.


    Thank you for your help!


    Regards,

Participate now!

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