0
Thanks

A few words of thanks would be greatly appreciated.

Excel - A macro to edit file name




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.
0
Thanks

A few words of thanks would be greatly appreciated.

Ask a question
CCM is a leading international tech website. Our content is written in collaboration with IT experts, under the direction of Jean-François Pillou, founder of CCM.net. CCM reaches more than 50 million unique visitors per month and is available in 11 languages.
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).

Subscribe To Our Newsletter!

The Best of CCM in Your Inbox

Subscribe To Our Newsletter!