0

below I have a code for saving file as...however, I need to name the file with the vale from cells A10, B3 and B4. I tried to add there:

InitialName = Range("A1") & "" & Range("B1") & "" & Range("C1")

Unfortunately it never worked for me.

Sub filesave()

Dim bFileSaveAs As Boolean
bFileSaveAs = Application.Dialogs(xlDialogSaveAs).Show
If Not bFileSaveAs Then MsgBox "User cancelled", vbCritical

End Sub

EDIT: I would need a suggested name in the "Save as" dialog box based on values from A10 & B3 & B4. enter image description here

Jeame
  • 49
  • 1
  • 6
  • Are you trying to change the default suggestion for save as? https://www.howtogeek.com/220794/how-to-change-the-default-file-name-used-when-saving-word-documents/ – QHarr May 13 '18 at 18:32
  • If so I did that here https://stackoverflow.com/questions/49059857/change-default-filename-in-saveas-dialog May help. – QHarr May 13 '18 at 18:36
  • FIrst: Why use "" in between ranges? Second: Don't you just want to use: ThisWorkbook.Range("A1") & Range("B1") & Range("C1") & ".xlsm", FileFormat:=52 – JvdV May 13 '18 at 18:41
  • Hello QHarr, I think I need sth. slighty different. Hello JvdV, I tried to apply your advice, but it was not working for me. I also Edited my initial post to make it clear a bit. – Jeame May 13 '18 at 19:44
  • Excuse my slip of mind: ThisWorkbook.SaveAs Range("A10") & Range("B3") & Range("B4") & ".xlsm", FileFormat:=52 – JvdV May 13 '18 at 20:17
  • This looks good, one final question, yur code saves the file to the location where is the original sheet, right? If I would like to add there a set location? Thanks! – Jeame May 13 '18 at 21:06

1 Answers1

0

With your explaination I now better understand what you try to do. So here is the code that will do exactly what you try to achieve:

Application.Dialogs(xlDialogSaveAs).Show Range("A10") & Range("B3") & Range("B4") 
JvdV
  • 70,606
  • 8
  • 39
  • 70