Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have cells with data such as
0.5 ml 1ml 560 gm 373 milliliters and need a function to extract the number part of these. I found a formula that sort of works, ----------------- Function ExtractNumber(rCell As Range) Dim iCount As Integer, i As Integer Dim sText As String Dim lNum As String '''''''''''''''''''''''''''''''''''''''''' 'Written by OzGrid Business Applications 'www.ozgrid.com 'Extracts a number from a cell containing text and numbers. '''''''''''''''''''''''''''''''''''''''''' sText = rCell For iCount = Len(sText) To 1 Step -1 If IsNumeric(Mid(sText, iCount, 1)) Then i = i + 1 lNum = Mid(sText, iCount, 1) & lNum End If If i = 1 Then lNum = CInt(Mid(lNum, 1, 1)) Next iCount ExtractNumber = CLng(lNum) End Function ----------------------- However this formula seems to ignore decimal points and for example the 0.5 is returned as 5. All I want is a function to return just number part and not the units. Any ideas? -Andrew V. Romero |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How to extract text from number/text cell | Excel Worksheet Functions | |||
Extract a number(s) from a text string | Excel Discussion (Misc queries) | |||
Extract a number from a variable text string | Excel Discussion (Misc queries) | |||
extract number and use in formula from text & numbers in cell | Excel Worksheet Functions | |||
Extract number from text/number string.. | Excel Discussion (Misc queries) |