-1

enter image description here

I'd like the output to be 10 and 200.

shrivallabha.redij
  • 5,832
  • 1
  • 12
  • 27
  • 1
    Does this answer your question? [Extract digits from string - Google spreadsheet](https://stackoverflow.com/questions/41752141/extract-digits-from-string-google-spreadsheet) – Hooded 0ne Oct 27 '20 at 05:44
  • @MarciSlaughter. Your suggested answer will produce wrong results. Please [see why](https://stackoverflow.com/a/64550850/1527780) – marikamitsos Oct 27 '20 at 16:13

2 Answers2

1

@Catherine, your image doesn't show the range where your raw data resides nor where you want the results. And you've only allowed us to see two examples. But based on those two examples, and supposing that your raw data were in B2:B, delete everything from A2:A (or use another empty column) and place the following formula in A2 (or parallel):

=ArrayFormula(IF(B2:B="",, REGEXEXTRACT(B2:B, "- ([0-9]+)")))

This reads (in plain English): "If any cell from B2 down is blank, don't put anything in the results column. If it's not blank, extract from whatever is in the current row in Column B any group of numbers that follows a dash-and-space combination."

Everything in quotes within the REGEXEXTRACT denotes what to look for, while what is in parentheses denotes the part of that to extract.

If you need to count or do math with the extracted portions, add a VALUE wrap to the REGEXEXTRACT like this:

=ArrayFormula(IF(B2:B="",, VALUE(REGEXEXTRACT(B2:B, "- ([0-9]+)"))))
Erik Tyler
  • 9,079
  • 2
  • 7
  • 11
1

You should also try

=ArrayFormula(IFERROR(REGEXEXTRACT(B2:B, ".* (\d+) /.*")*1))

Or omit the arrayformula and drag down

=IFERROR(REGEXEXTRACT(B2, ".* (\d+) /.*")*1)

Other suggested solution may work for the given example.

Think ahead though for a more concrete solution in situations like

                               column B                                      
 -------------------------------------------------------------------------- 
  Medical Face Shield - Pack - 10 / Next Day Shipping                       
  KN95 Protective Mask - Type B - Carton - 200 / Next Day Shipping          
  MM - 33 Face Shield - 555 / - Type B - Carton - 1000 / Next Day Shipping  

enter image description here

Functions used:

marikamitsos
  • 10,264
  • 20
  • 26