Excel - A macro to edit file name

May 2017




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.

Related


Published by aakai1056. Latest update on September 1, 2012 at 07:52 AM by jak58.
This document, titled "Excel - A macro to edit file name," is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (ccm.net).