View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
[email protected] paul.robinson@it-tallaght.ie is offline
external usenet poster
 
Posts: 789
Default Extract a value from mid string

Hi
Just seen Vergel's code - much better!
Paul

On Mar 20, 3:41 pm, wrote:
Hi
Public function ExtractIt(myString as Variant) as Long
TempString = ""
'delete bit up to and including first dot
TempString = Right(Cstr(myString),len(myString)-Instr(myString,"."))
'extract up to second dot. assuming there is one
ExtractIt = Val(Left(TempString, Instr(TempString,"."))
end function

Sub tester()
For each cell in Range("A1:A100")
myVariable = ExtractIt(Cell.Value)
msgbox myVariable
next cell
end sub

regards
Paul

On Mar 20, 3:14 pm, XP wrote:



Given data like the following:


B.3.54
A.14.1
BC.323.88493
ABC.1.4993


I need to always extract the first value after the first dot (reading left
to right). So, continuing in the example shown, I need to get: 3; 14; 323;
and 1;


This runs on one line at a time so I need to be able to just get one value
at a time copied into a variable. Can someone please post example code that
can do this?


Thanks much in advance.- Hide quoted text -


- Show quoted text -