Home Python Excel - A macro to edit file name

Excel - A macro to edit file name

excel20230615173449.jpg

Issue

I have a macro code to save a file name to a form. My file takes two cells (F4) and (H20) to create a backup file. I wan put a hyphen between the two cells nd tried this:

File_Name = Worksheets("Sheet1").Range("F4") & Worksheets("Sheet1").Range("H20") & ".xlsm"

The result generated takes this form F4H20 and I wish it was F4-H20.

Solution

Try this:

File_Name = Worksheets("Sheet1").Range("F4") & "-" & Worksheets("Sheet1").Range("H20") & ".xlsm"

Thanks to f894009 for this tip.

  • Python

LEAVE A REPLY

Please enter your comment!
Please enter your name!