GreyFox8991

New Member
Joined
Jul 20, 2022
Messages
20
Office Version
  1. 2016
Platform
  1. Windows
Greetings Excel Community,

I am attempting to insert or duplicate a string value within a naming convention without having to do input manually. Is there a formula or a macro code that might be able to complete this possibly? Via the example below, I am attempting to duplicate the ID value twice so the end result is the format presented in the UpdatedNamingConvention, so the ID value appears twice.

Book4
ABC
1IDCurrentNamingConventionUpdatedNamingConvention
2999999POTTER_HARRY_999999.txtPOTTER_HARRY_999999_999999.txt
Sheet1
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
So, you have what you show in columns A and B to start, and you want what is in column C?

If that is the case, try this formula in cell C2:
Excel Formula:
=LEFT(B2,LEN(B2)-4) & "_" & A2 & RIGHT(B2,4)
 
Upvote 0
Solution
I think that would only work if it was always a duplication.

Perhaps:
=SUBSTITUTE(B2,".","."&A2&".")
The OP said "I am attempting to duplicate the ID value twice so the end result is the format presented in the UpdatedNamingConvention", hence, my formula.
 
Upvote 0
But the op also said insert or duplicate, so I guess it just depends on how you interpret that. Otherwise, there is no reason for the value in column A, you could just duplicate the part after the last _
 
Upvote 0
But the op also said insert or duplicate, so I guess it just depends on how you interpret that. Otherwise, there is no reason for the value in column A, you could just duplicate the part after the last _
I assumed the value was in the first column because it was used to create the value in the second column (the original file name) and that the OP now wanted to modify it to duplicate the number in the name (and put that in the third column). I figured as long as the values were already existing, that I would use them. And yes, I agree, we need a clarification from the OP.
 
Upvote 0
my first question would be....does Cell A2, go at the END of the string in B2 or the middle of it? Because they're named the same it's hard to differentiate.
 
Upvote 0
Another option is
Excel Formula:
=REPLACE(B2,FIND(".",B2),0,"_"&A2)
 
Upvote 0

Forum statistics

Threads
1,215,069
Messages
6,122,954
Members
449,095
Latest member
nmaske

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top