Need Help On A Formula

ranjith2523

Board Regular
Joined
Apr 29, 2014
Messages
137
Office Version
  1. 365
Hello Experts,

Again, i am seeking your help on a formula which breaking my head. I almost wrote the formula but it is not working as expected.

Initially what i did is, In column A (from cell A2) i just used the Length formula to get the length of the product from column B (from cell B2).

Then i applied the below formula in from Cell C2 to get the expected results. It is almost working but not working for the products like "3XLK462R-A21" hence seeking your help to simplify my formula and get the desired result.

=IF(OR(B2="",B2=" ",B2="0"),"",IF(OR(A2>=11),IF(MID(B2,7,1)="R",LEFT(B2,6)&RIGHT(B2,4)),IF(RIGHT(B2,1)="R",LEFT(B2,A2-1))))

Rmkt Skus.xlsm
FGH
1ProductsExpected ResultComments
2AD058AR#001AD058A#001F2 cell part number contains # and the length is greater or equal to 11. In this case, the R should be removed which appear just before the # and rest appear as it is in cell G2.
3591973R-B21591973-B21F3 cell part number contains hyphen and the length is greater or equal to 11. In this case, the R should be removed which appear just before the last occurrence of hyphen and rest should appear as it is in cell G3.
4A4882ARA4882AF4 cell part number does not contain # or hyphen so the expectation is to remove the R from the end and rest should appear as it is in Cell G4.
5640QR-B3BaseF5 cell part number length is less then 11 so the result should appear as "Base"
6A58AR#001BaseF6 cell part number length is less then 11 so the result should appear as "Base"
73R-A0824-AABaseF7 Cell part number does not have R just before the last occurrence of hyphen hence it should be retain as "Base"
83R-A0824R-AA3R-A0824-AAF8 cell part number contains hyphen and the length is greater or equal to 11. In this case, the R should be removed which appear just before the last occurrence of hyphen and rest should appear as it is in cell G8.
92T-SC008-SRBaseF8 cell contains hypen and No R found just before the last occurrence of hyphen hence it should be retains as "Base"
Sheet1


Thanks for all your help in advance.

Regards,
Ranjith
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
What version of Excel are you using?

I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)
 
Upvote 0
What version of Excel are you using?

I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)
Hi Fluff,

Good to see you again !!!

Sorry for that, i am using Excel 365 and updated it in "Account Details". Are you not able to see my spread sheet ?

Please let me know what can i do to get the solution.

Thanks for all your help in advance.

Regards,
Ranjith
 
Upvote 0
Thanks for that, how about
+Fluff 1.xlsm
ABD
1ProductsExpected Result
2AD058AR#001AD058A#001AD058A#001
3591973R-B21591973-B21591973-B21
4A4882ARA4882AA4882A
5640QR-B3BaseBase
6A58AR#001BaseBase
73R-A0824-AABaseBase
83R-A0824R-AA3R-A0824-AA3R-A0824-AA
92T-SC008-SRBaseBase
Master
Cell Formulas
RangeFormula
D2:D9D2=LET(L,LEN(A2),sub,FIND("||",SUBSTITUTE(A2,"-","||",L-LEN(SUBSTITUTE(A2,"-","")))),IF(L<11,IF(RIGHT(A2)="R",LEFT(A2,L-1),"Base"),IF(MID(A2,IFERROR(FIND("#",A2)-1,1),2)="R#",SUBSTITUTE(A2,"R#","#"),IF(MID(A2,sub-1,1)="R",REPLACE(A2,sub-1,1,""),"Base"))))
 
Upvote 0
Thanks for that, how about
+Fluff 1.xlsm
ABD
1ProductsExpected Result
2AD058AR#001AD058A#001AD058A#001
3591973R-B21591973-B21591973-B21
4A4882ARA4882AA4882A
5640QR-B3BaseBase
6A58AR#001BaseBase
73R-A0824-AABaseBase
83R-A0824R-AA3R-A0824-AA3R-A0824-AA
92T-SC008-SRBaseBase
Master
Cell Formulas
RangeFormula
D2:D9D2=LET(L,LEN(A2),sub,FIND("||",SUBSTITUTE(A2,"-","||",L-LEN(SUBSTITUTE(A2,"-","")))),IF(L<11,IF(RIGHT(A2)="R",LEFT(A2,L-1),"Base"),IF(MID(A2,IFERROR(FIND("#",A2)-1,1),2)="R#",SUBSTITUTE(A2,"R#","#"),IF(MID(A2,sub-1,1)="R",REPLACE(A2,sub-1,1,""),"Base"))))
This is what exactly i need.. You are always helpful to me.. Thanks a lot from bottom of my heart :)
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,840
Messages
6,121,895
Members
449,058
Latest member
Guy Boot

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