Help Update MID function with additional character based on same value in multiple of 3.

gargilang

New Member
Joined
Jun 17, 2022
Messages
19
Office Version
  1. 365
Platform
  1. Windows
Hello, I need help with updating below formula to add some characters to make it more unique among themselves. Please see below example in yellow.
Book1
ABCD
1DataItem
21_1111_aaa11111111TRUE
32_22222_aaa2222222222TRUE
43_22222_bbb2222222222FALSE
54_22222_ccc2222222222FALSE
65_3333_aaa33333333-1TRUE
76_3333_bbb33333333-1FALSE
87_3333_ccc33333333-1FALSE
98_3333_ddd33333333-2TRUE
109_44444_aaa4444444444-1TRUE
1110_44444_bbb4444444444-1FALSE
1211_44444_ccc4444444444-1FALSE
1312_44444_ddd4444444444-2TRUE
1413_44444_eee4444444444-2FALSE
1514_44444_fff4444444444-2FALSE
1615_44444_ggg4444444444-3TRUE
Sheet1
Cell Formulas
RangeFormula
B2:B16B2=SUBSTITUTE(MID(A2,FIND("_",A2,1)+1,5),"_","")
D2:D16D2=MOD(COUNTIF($B$2:$B2,B2),3)=1

If the same items is repeated more than 3, than I would need them to be unique among themselves to separate them. The character to differentiate can be anything (-1, -2, -3 or a, b, c). Probably combining the Mod function that I use on the other cell?
I hope it makes sense. Thank you for all the help in advance.
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
C2:
Code:
=TRIM(MID(SUBSTITUTE(A2,"_",REPT(" ",10)),10,10))&IF(COUNTIF($A$2:$A$16,"*_" &TRIM(MID(SUBSTITUTE(A2,"_",REPT(" ",10)),10,10))&"_*")>3,"-"&INT((COUNTIF($A$2:$A2,"*_" &TRIM(MID(SUBSTITUTE(A2,"_",REPT(" ",10)),10,10))&"_*")-1)/3)+1,"")
 
Upvote 0
Solution
C2:
Code:
=TRIM(MID(SUBSTITUTE(A2,"_",REPT(" ",10)),10,10))&IF(COUNTIF($A$2:$A$16,"*_" &TRIM(MID(SUBSTITUTE(A2,"_",REPT(" ",10)),10,10))&"_*")>3,"-"&INT((COUNTIF($A$2:$A2,"*_" &TRIM(MID(SUBSTITUTE(A2,"_",REPT(" ",10)),10,10))&"_*")-1)/3)+1,"")
Thank you Sir! I love you from the bottom of my heart!
 
Upvote 0
Nice to hear it works.
If your data reach several thousand rows, formula may cause PC slow down.
If so, come back and VBA code will be offerred.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,178
Members
453,021
Latest member
Justyna P

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