SOLVED

File Name Macro

New Contributor

I have a Macro (ExcelFileName) in the attached file that creates a new name for the file based on the highlighted cells in the screenshot below. The naming convention that we use is as follows:

 

Rule Code_Short Description_Dollar Amount_Cent Amount_Initials.xlsm

 

westcottk_1-1626115735663.jpeg

 

 

This is what I would like to be produced for the attached entry: YRA_ReclassRev_400_00_KAW.xlsm

This is what is currently being produced by the macro: YRA_ReclassRev_400_KAW.xlsm

 

Unfortunately, I am not able to get the Macro to include the “_00” when there is a round number such as $400.00.  The Macro works in cases where we don’t have a round number such as $400.87.  Here is  the part of the Macro that creates the file name based on the various cell values with Cell K13 being the $400.00 in this example. 

 

strName = Replace(Range("k15") & "_" & Range("k5") & "_" & Range("k13") & "_" & Range("k4"), " ", "")

strName = Replace(strName, ".", "_")

 

Any suggestions would be greatly appreciated.

2 Replies
best response confirmed by westcottk (New Contributor)
Solution

@westcottk 

Use

    strName = Replace(Range("k15") & "_" & Range("k5") & "_" & Format(Range("k13"), "0.00") & "_" & Range("k4"), " ", "")
    strName = Replace(strName, ".", "_")
Thanks so much, Hans!