mardi 6 août 2019

Can I use an IF and Else to define a string?

I want to save my workbook with a filename depending on data in one of the cells. This isn't too difficult, but I want to use a three character code instead of the full cell contents in the original.

So if cell F2 contains "United States" then Dim = "USA" Else if it contains "Great Britain" then "GBR" Else if it contains "India" then "IND" Else "JAP"

Then at the bottom: Save as Filename:= "C:\My documents\" & Dim from above & "File" & Format(date, "yyyymmdd") & ". xlsx"

So the file name depends on a shortened version of the F2 cell's contents.

Thanks in advance.

Aucun commentaire:

Enregistrer un commentaire