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: 5
Default Extract Digits Questions

I found a nice function and modified it to take out digits (and a
decimal) from a cell however don't get one line. 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
Else
If flag = 1 Then Exit Function
End If
Next i
End Function
---------------------------------
This seems to work, however if the cell is 12.3mg it will display the
result as 123. If I comment out the ExtractDigits = ExtractDigits * 1
then it returns it as 12.3 which is what I want. So what is this
ExtractDigits = ExtractDigits * 1 doing? I can't figure out why it
changes 123 to 12.3.

Thanks,
Andrew V. Romero

 
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 do I extract the last three digits from each cell in column? PeggyT Excel Discussion (Misc queries) 5 April 4th 23 11:22 AM
To extract the number if there is niumeric in right most digits pol Excel Discussion (Misc queries) 4 October 16th 08 07:21 AM
how to extract digits from a row of numbers preydd Excel Worksheet Functions 2 September 3rd 08 04:32 PM
I need to extract the first 3 digits from a cell (ex: AAG12345)? Rob Excel Worksheet Functions 6 April 21st 07 11:45 PM
how do I extract hex digits in a cell and convert to binary prs_013 Excel Worksheet Functions 3 March 17th 06 07:14 AM


All times are GMT +1. The time now is 03:15 AM.

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"