Home |
Search |
Today's Posts |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks!
-- Gary''s Student - gsnu200776 "Rick Rothstein (MVP - VB)" wrote: If c Like "#" Or c = "." Then Or... If c Like "[0-9.]" Then Rick "Gary''s Student" wrote in message ... You were very, very close: Function numit(r As Range) As Double Dim s As String, s2 As String, c As String Dim b As Boolean b = False s2 = "" s = r.Value l = Len(s) For i = 1 To l c = Mid(s, i, 1) If c Like "#" Or c = "." Then s2 = s2 & c b = True Else If b = True Then Exit For End If Next numit = --s2 End Function -- Gary''s Student - gsnu200776 "caroline" wrote: Hi, This is brilliant thanks. Is there anyway I can also select decimals like in 1.5 in ft1.5drt? I tried to adapt your code If c Like "#" or "." Then but it did not work Thanks again -- caroline "Gary''s Student" wrote: How about: Function numit(r As Range) As Double Dim s As String, s2 As String, c As String Dim b As Boolean b = False s2 = "" s = r.Value l = Len(s) For i = 1 To l c = Mid(s, i, 1) If c Like "#" Then s2 = s2 & c b = True Else If b = True Then Exit For End If Next numit = --s2 End Function -- Gary''s Student - gsnu200776 "caroline" wrote: hello, I am using the following code to extract numbers from a string http://www.ozgrid.com/VBA/ExtractNum.htm however when I have strings like WS123ABC45cft, I would like to extract only the first set of number"123". The code provided extracts "12345" Do you know how to correct the code? Please note that the number of numbers and letters are variables so I cannot use LEFT or RIGHT. thanks -- caroline |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Extract numbers from a string of text | Excel Discussion (Misc queries) | |||
extract numbers from a string | Excel Worksheet Functions | |||
Only extract numbers from a string of text | Excel Discussion (Misc queries) | |||
Extract Numbers From String | Excel Programming | |||
Extract numbers from a string ? | Excel Programming |