need only data

sksanjeev786

Well-known Member
Joined
Aug 5, 2020
Messages
881
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi Team,

I have data in various formate. can I get any formula to find only data. There will be % space on random data but I need only data i.e 32 data can be in single digit as well. (instead of 32 it can be 8 with all below condtion)

32%A, (%)
32%ab,
32AB, (No Space )
32 AB(only has Space)

Thanks in Advance.
Regards,
Sanjeev
 
Assuming the numerical part is always the first thing in the string like your examples then this formula should also work for you, including with decimals.
Further, this one will not fail if rows are subsequently added at the top of the sheet.

sksanjeev786.xlsm
BC
1
2raw
332%A, (%)32
432%ab,32
532AB, (No Space )32
632 AB(only has Space)32
71CD DD1
8333%SX VV333
932%32
100.32%xx vb0.32
110.320.32
Sheet1
Cell Formulas
RangeFormula
C3:C11C3=LEFT(B3,MATCH(TRUE,INDEX(ISERR(MID(SUBSTITUTE(B3,".",1)&"x",ROW(INDEX(A:A,1):INDEX(A:A,20)),1)+0),0),0)-1)+0


Thank you, Sir.

it work with decimal data as well.

Thank you again for your hard work.

Regards,
Sanjeev
 
Upvote 0

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Assuming the numerical part is always the first thing in the string like your examples then this formula should also work for you, including with decimals.
Further, this one will not fail if rows are subsequently added at the top of the sheet.

sksanjeev786.xlsm
BC
1
2raw
332%A, (%)32
432%ab,32
532AB, (No Space )32
632 AB(only has Space)32
71CD DD1
8333%SX VV333
932%32
100.32%xx vb0.32
110.320.32
Sheet1
Cell Formulas
RangeFormula
C3:C11C3=LEFT(B3,MATCH(TRUE,INDEX(ISERR(MID(SUBSTITUTE(B3,".",1)&"x",ROW(INDEX(A:A,1):INDEX(A:A,20)),1)+0),0),0)-1)+0


Hi Peter,

Just wanted to thank you again on the above formula.

I have shared with my team and they are really impressed and said one-word "Fabulous " with the formula.

But I team I asking about explanation about formula. Do we have any way so that I can explain on formula. ie. why we use Row and Index function at the end.

=LEFT(B3,MATCH(TRUE,INDEX(ISERR(MID(SUBSTITUTE(B3,".",1)&"x",ROW(INDEX(A:A,1):INDEX(A:A,20)),1)+0),0),0)-1)+0

Thank you in advance. :)
Sanjeev
 
Upvote 0
Hi Peter,

Just wanted to thank you again on the above formula.

I have shared with my team and they are really impressed and said one-word "Fabulous " with the formula.
You and your team are welcome. :)

why we use Row and Index function at the end.

=LEFT(B3,MATCH(TRUE,INDEX(ISERR(MID(SUBSTITUTE(B3,".",1)&"x",ROW(INDEX(A:A,1):INDEX(A:A,20)),1)+0),0),0)-1)+0
The blue highlighted part of the formula produces the sequence of numbers 1,2,3,4,....,20
This is then used to look individually at the first 20 characters in the cell to locate the first one that is not a digit (excluding "." which has temporarily been substituted with a 1.
I have used 20 as I would not expect any leading number to be that long and perhaps we could have used a smaller number.

sandy666's formula does a similar thing with the much shorter ROW($1:$25)

I have gone for the longer version as it makes the formula more robust. To demonstrate, here in my formula in column C and sandy666's formula in col D. Both produce identical results for these (non-decimal) samples

sksanjeev786.xlsm
BCD
132%A, (%)3232
232%ab,3232
332AB, (No Space )3232
432 AB(only has Space)3232
51CD DD11
6333%SX VV333333
732%3232
Sheet1
Cell Formulas
RangeFormula
C1:C7C1=LEFT(B1,MATCH(TRUE,INDEX(ISERR(MID(SUBSTITUTE(B1,".",1)&"x",ROW(INDEX(A:A,1):INDEX(A:A,20)),1)+0),0),0)-1)+0
D1:D7D1=SUMPRODUCT(MID(0&B1,LARGE(INDEX(ISNUMBER(--MID(B1,ROW($1:$25),1))*ROW($1:$25),0),ROW($1:$25))+1,1)*10^ROW($1:$25)/10)


But suppose that you, or another user, want to add some more information at the top of the sheet and subsequently insert one or more new rows. Here is one such result where the col C formula still returns the correct results but the col D one no longer does.

sksanjeev786.xlsm
BCD
1
232%A, (%)32#NUM!
332%ab,32#NUM!
432AB, (No Space )32#NUM!
532 AB(only has Space)32#NUM!
61CD DD1#NUM!
7333%SX VV333#NUM!
832%32#NUM!
Sheet1
Cell Formulas
RangeFormula
C2:C8C2=LEFT(B2,MATCH(TRUE,INDEX(ISERR(MID(SUBSTITUTE(B2,".",1)&"x",ROW(INDEX(A:A,1):INDEX(A:A,20)),1)+0),0),0)-1)+0
D2:D8D2=SUMPRODUCT(MID(0&B2,LARGE(INDEX(ISNUMBER(--MID(B2,ROW($2:$26),1))*ROW($2:$26),0),ROW($2:$26))+1,1)*10^ROW($2:$26)/10)
 
Upvote 0
You and your team are welcome. :)


The blue highlighted part of the formula produces the sequence of numbers 1,2,3,4,....,20
This is then used to look individually at the first 20 characters in the cell to locate the first one that is not a digit (excluding "." which has temporarily been substituted with a 1.
I have used 20 as I would not expect any leading number to be that long and perhaps we could have used a smaller number.

sandy666's formula does a similar thing with the much shorter ROW($1:$25)

I have gone for the longer version as it makes the formula more robust. To demonstrate, here in my formula in column C and sandy666's formula in col D. Both produce identical results for these (non-decimal) samples

sksanjeev786.xlsm
BCD
132%A, (%)3232
232%ab,3232
332AB, (No Space )3232
432 AB(only has Space)3232
51CD DD11
6333%SX VV333333
732%3232
Sheet1
Cell Formulas
RangeFormula
C1:C7C1=LEFT(B1,MATCH(TRUE,INDEX(ISERR(MID(SUBSTITUTE(B1,".",1)&"x",ROW(INDEX(A:A,1):INDEX(A:A,20)),1)+0),0),0)-1)+0
D1:D7D1=SUMPRODUCT(MID(0&B1,LARGE(INDEX(ISNUMBER(--MID(B1,ROW($1:$25),1))*ROW($1:$25),0),ROW($1:$25))+1,1)*10^ROW($1:$25)/10)


But suppose that you, or another user, want to add some more information at the top of the sheet and subsequently insert one or more new rows. Here is one such result where the col C formula still returns the correct results but the col D one no longer does.

sksanjeev786.xlsm
BCD
1
232%A, (%)32#NUM!
332%ab,32#NUM!
432AB, (No Space )32#NUM!
532 AB(only has Space)32#NUM!
61CD DD1#NUM!
7333%SX VV333#NUM!
832%32#NUM!
Sheet1
Cell Formulas
RangeFormula
C2:C8C2=LEFT(B2,MATCH(TRUE,INDEX(ISERR(MID(SUBSTITUTE(B2,".",1)&"x",ROW(INDEX(A:A,1):INDEX(A:A,20)),1)+0),0),0)-1)+0
D2:D8D2=SUMPRODUCT(MID(0&B2,LARGE(INDEX(ISNUMBER(--MID(B2,ROW($2:$26),1))*ROW($2:$26),0),ROW($2:$26))+1,1)*10^ROW($2:$26)/10)


Thank you Peter for the detailed information. I will convey the above explanation to my team member and thanks a lot for your valuable time on this:)

Regards,
Sanjeev.
 
Upvote 0

Forum statistics

Threads
1,214,599
Messages
6,120,453
Members
448,967
Latest member
grijken

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