1

I would like to move numbers from one cell to another, or in some way extract numbers from one cell to another, with the number being removed from its previous cell.

Picture of how i want the data to be presented

enter image description here

JvdV
  • 70,606
  • 8
  • 39
  • 70

2 Answers2

4

Try:

enter image description here

Formula in B1:

=--CONCAT(IFERROR(--MID(A1,SEQUENCE(LEN(A1)),1),""))

Or, in case you have values like Test1 Test2 123456:

=--LET(a,TEXTSPLIT(A1," "),FILTER(a,ISNUMBER(--a)))

EDIT: The question is not solely about moving numbers but about presenting input without the number and the number seperately. Therefor try:

enter image description here

Formula in C1:

=LET(a,TEXTSPLIT(A1," "),HSTACK(TEXTJOIN(" ",,FILTER(a,ISERROR(--a))),--FILTER(a,ISNUMBER(--a))))
JvdV
  • 70,606
  • 8
  • 39
  • 70
3

I would suggest to use FILTERXML() to extract numeric nodes.

=TRANSPOSE(FILTERXML("<t><s>"&SUBSTITUTE(A1," ","</s><s>")&"</s></t>","//s[number()=.]"))
  • Here "<t><s>"&SUBSTITUTE(A1," ","</s><s>")&"</s></t>" will construct a valid xml string.
  • FILTERXML() will process that xml string and xPath parameter //s[number()=.] will return only numeric nodes.

To know more about FILTERXML() read this post by @JvdV.

enter image description here

Harun24hr
  • 30,391
  • 4
  • 21
  • 36
  • This will stay a nice way to split text. But since TEXTSPLIT is introduced I think we'll be using that more often. Also because it's easier to write. The regex handling is definitely useful though. Too bad it's only useful for Windows environment. – P.b Oct 14 '22 at 16:51
  • 1
    @P.b That is limitation of `FILTERXML()` but in some case it is really nice. – Harun24hr Oct 15 '22 at 02:12