Distinguishing between 2x and 12x with IF(ISNUMBER(SEARCH

Mr2017

Well-known Member
Joined
Nov 28, 2016
Messages
644
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi

I have a sheet where I'm extracting the pack size of a product using IF(ISNUMBER(SEARCH then multplying that pack size by the units of the product.

However, there are some products where the pack size is 2 and others where it is 12 eg

Chocolates 2x250g
Chocolates 12x250g

Excel can't seem to distinguish the difference between the 2x and 12x?

I used the data below - if you copy and paste it in cell A1, it should go up to column E.


Original unitsFormula resultCorrect numbers (units x pack size)Multipack Description Pack size
100020002000Chocolates 2x250g2
1000200012000Chocolates 12x250g12

<colgroup><col><col><col><col><col></colgroup><tbody>
</tbody>



The formula I used is in cell B2. However, when you drag it down to B3, it doesn't work? Does anyone know how to fix this? Thanks in advance.

=IF(A2="","",IF(ISNUMBER(SEARCH("2x",D2)),A2*2,IF(ISNUMBER(SEARCH("12X",D2)),A2*12,"")))
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Because your are searching for 2X in a string that contains 2X (12X) your first isnumber will be true for 2X and 12X
Try testing for 12X first so that if it is 2 you get false with the first isnumber.
Code:
=IF(A2="","",IF(ISNUMBER(SEARCH("12x",D2)),A2*12,IF(ISNUMBER(SEARCH("2X",D2)),A2*2,"")))
 
Last edited:
Upvote 0
Thank you both!

I tried what Mark 885 suggested

i.e putting a space before the 2 in the 2x case.

and it worked!

I will also consider using the method you suggested, Scott T, in future.

Thanks again for both responding.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,925
Messages
6,122,301
Members
449,078
Latest member
nonnakkong

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