Calculate a cell value based on a specific string in a separate cell

vipin30sep

New Member
Joined
Feb 14, 2019
Messages
20
Hello,

The first column contains a string of values as mentioned below . In 2nd column, I need to strip out specific info from Col 1 (as mentioned below). I tried using a formula like this - =LOOKUP(MID(AS2,12,3),{"Lar","X-L"," Sma"},{"Large","X-Large","Small"}) , but its not calculating the values correctly. Appreciate if you can help here. Thanks in advance!

[{"name": "wedding_type", "value": "Mr. & Mrs."}, {"name": "shirt_size", "value": "X-Large"}]

<tbody>
</tbody>
Mr. & Mrs. X-Large

<tbody>
</tbody>
[{"name": "wedding_type", "value": "Mr. & Mrs."}, {"name": "shirt_size", "value": "Large"}]

<tbody>
</tbody>
Mr. & Mrs. Large
[{"name": "wedding_type", "value": "Mr. & Mrs."}, {"name": "shirt_size", "value": "Small"}]

<tbody>
</tbody>
Mr. & Mrs. Small
[{"name": "wedding_type", "value": "Mr. & Mrs."}, {"name": "shirt_size", "value": "2XL"}]

<tbody>
</tbody>
Mr. & Mrs. 2XL
[{"name": "wedding_type", "value": "Mr. & Mrs."}, {"name": "shirt_size", "value": "Medium"}]

<tbody>
</tbody>
Mr. & Mrs. Medium

<tbody>
</tbody>
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Hi @navic,

So this is not about sorting, it is the addition of one more condition to your original formula. I have added the condition in below formula, is there any better way to put this,

Code:
=IF(MID(AR2,37,10)="Mr. & Mrs.",MID(AR2,37,10)&" / "&IFERROR(LEFT(MID(AR2,84,10),FIND(TEXT("""","00"),MID(AR2,84,10))-1),MID(AR2,84,10)),IF(MID(AR2,37,10)="Mrs. & Mrs",MID(AR2,37,11)&" / "&IFERROR(LEFT(MID(AR2,85,10),FIND(TEXT("""","00"),MID(AR2,85,10))-1),MID(AR2,85,10)),""))




I do not understand you.
If this is your result and you want to sort if there are more options then use the formula that gave @tyija1995 in post #9

<tbody>
</tbody>
 
Upvote 0
is there any better way to put this
As far as I can see, you fixed the starting number in the MID formula.
Example fixed start number is 84 or 37
Rich (BB code):
MID(A2;84;10)
If the conditioned cell is always the same number of characters it's okay.

I gave you two formulas in post # 4.
The first formula is for a variable number of characters
The second formula is for a fixed number of characters (in this formula you can use fixed start number)

If your last formula returns the desired result, I think you not need to change anything.
I do not know why you're in an argument "value_if_false" using the formula?
This formula below is a little shorter and uses it if it returns the expected results. Argument "value_if_false" equal "" or blank.
Rich (BB code):
=IF(MID(A2,37,10)="Mr. & Mrs.",MID(A2,37,10)&" / "&IFERROR(LEFT(MID(A2,84,10),FIND(TEXT("""","00"),MID(A2,84,10))-1),MID(A2,84,10)),"")
 
Last edited:
Upvote 0
Thanks @navic,

It works. Appreciate your help as always. Actually there is a macro that I run which has this formula, it breaks if I don't add the argument to have FALSE. All good. Appreciate your help.

As far as I can see, you fixed the starting number in the MID formula.
Example fixed start number is 84 or 37
Rich (BB code):
MID(A2;84;10)
If the conditioned cell is always the same number of characters it's okay.

I gave you two formulas in post # 4.
The first formula is for a variable number of characters
The second formula is for a fixed number of characters (in this formula you can use fixed start number)

If your last formula returns the desired result, I think you not need to change anything.
I do not know why you're in an argument "value_if_false" using the formula?
This formula below is a little shorter and uses it if it returns the expected results. Argument "value_if_false" equal "" or blank.
Rich (BB code):
=IF(MID(A2,37,10)="Mr. & Mrs.",MID(A2,37,10)&" / "&IFERROR(LEFT(MID(A2,84,10),FIND(TEXT("""","00"),MID(A2,84,10))-1),MID(A2,84,10)),"")
 
Upvote 0

Forum statistics

Threads
1,214,914
Messages
6,122,211
Members
449,074
Latest member
cancansova

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