Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 15,768
Default How to locate the first digit in a cell, explained

So, to correct the formula you'd just need to add a length test

Or, use Harlan's formula where he expands it to use the MID function.

Biff

"T. Valko" wrote in message
...
That formula is more or less designed to be used as an argument for
extracting a number from a string. But, it can be used as is with a little
tweak.

The formula is concatenating the digits to the string. So, if:

A1 = XX

=MIN(SEARCH({0,1,2,3,4,5,6,7,8,9},A1&"0123456789") )

This portion:

A1&"0123456789"

Evaluates to:

XX0123456789

The 0 being in position 3

Basically, the expression: A1&"0123456789" is used as an error trap. So,
to correct the formula you'd just need to add a length test:

=IF(MIN(SEARCH({0,1,2,3,4,5,6,7,8,9},A1&"012345678 9"))LEN(A1),"",MIN(SEARCH({0,1,2,3,4,5,6,7,8,9},A 1&"0123456789")))

Biff

"Dave F" wrote in message
oups.com...
This formula doesn't seem to work correctly. If I have in cell A2 the
text XX the number 3 is returned. But there's no number in that
string of characters.

What am I missing?

The array formula proposed by the OP, however, reliably returns #N/A
if there is no number in the cell.

Dave

On May 10, 1:51 pm, Harlan Grove wrote:
"Peo Sjoblom" wrote...
This formula by Domenic is much more efficient

=MIN(SEARCH({0,1,2,3,4,5,6,7,8,9},A1&"0123456789" ))

...

FWIW, Aladin Arkyurek had posted a variant using FIND two months
before Domenic posted his using SEARCH, and there's an old Japanese
language post (3 years before Aladin's and Domenic's) showing this
exact idiom in the Google Groups archive.

Almost every Excel question has been asked and answered several times
before.







Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to validate a cell to insert from 9 digit number to 13 digit number. ramulu via OfficeKB.com Excel Worksheet Functions 1 February 21st 07 02:32 PM
How to validate a cell to insert from 9 digit number to 13 digit number. ramulu Excel Worksheet Functions 1 February 21st 07 10:00 AM
Counting Formulas -- Re-explained MAB Excel Worksheet Functions 2 January 12th 06 09:18 PM
Color a single digit in a mult-digit number cell Phyllis Excel Discussion (Misc queries) 6 November 17th 05 12:46 AM
16 DIGIT NUMBERS IN CELL WITHOUT LAST DIGIT BEING A ZERO jnkell Excel Worksheet Functions 2 December 18th 04 07:13 PM


All times are GMT +1. The time now is 12:15 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"