LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default Extract Digit Function Question

I found a function which seperates out numbers from letters. I
modified the formula to keep decimal points in. The formula works
well, however, the function came with a line that I don't understand.
The whole function is
------------------------------
Function ExtractDigits(cell As String) As Variant
'extract 1st continuous set of digits
'David McRitchie, 2001-09-26
Dim i As Long, flag As Long
flag = 0
ExtractDigits = ""
For i = 1 To Len(cell)
If Mid(cell, i, 1) = "0" And _
Mid(cell, i, 1) <= "9" Or _
Mid(cell, i, 1) = "." Then
flag = 1
ExtractDigits = ExtractDigits & Mid(cell, i, 1)
'ExtractDigits = ExtractDigits * 1 'not sure what this does?
but 12.3=123 with on
Else
If flag = 1 Then Exit Function
End If
Next i
End Function
-----------------------------
I don't see what the purpose of the ExtractDigits = ExtractDigits * 1
is and I don't get what it is doing. If it is enabled, like it was in
the original formula, then if the cell is 12.3mg it returns 123 while
if it is disabled, then it returns 12.3. How is this line removing the
decimal point?

Thanks,
Andrew V. Romero

PS: Sorry if this message comes thru multiple times, Google groups
seems to be acting up.

 
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 extract each digit from a number in one cell? greyhound girl Excel Discussion (Misc queries) 4 November 9th 06 07:42 PM
extract decimal place digit craig_100 Excel Worksheet Functions 3 November 29th 05 06:59 PM
Extract 10 digit number from string R. Choate Excel Programming 20 October 27th 05 10:47 PM
Extract 2, 3, 4 or 5-digit number from string Jim[_55_] Excel Programming 1 June 7th 05 03:22 PM
Extract 2, 3, 4 or 5-digit number from string Jim[_55_] Excel Programming 2 June 6th 05 06:48 PM


All times are GMT +1. The time now is 03:47 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"