View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jim Thomlinson[_3_] Jim Thomlinson[_3_] is offline
external usenet poster
 
Posts: 983
Default Need hlp capturing a certain pattrern from a column

Here is a function I use to find the first number in a string

Public Function FirstNumber(ByVal InputString As String) As Integer
Dim intCounter As Integer
Dim intStringLength As Integer
Dim intReturnValue As Integer

intReturnValue = -1
intStringLength = Len(InputString)

For intCounter = 1 To intStringLength
If IsNumeric(Mid(InputString, intCounter, 1)) Then
intReturnValue = intCounter
Exit For
End If
Next intCounter

FirstNumber = intReturnValue

End Function

place this code in a module and you will be able to use it as a formula in
your spreadsheet. You would use it something like.

=MID(A1, firstnumber(A1), 100)

Where "Test 123" was in A1

HTH

Jim Thomlinson


"Patrick" wrote:

Hi every1!!!

Need to isolate into a different column a value that was found into another
one.
Example:

COL1 COL2
test 123 123

Would like to copy the number part only into another column, using already
existing functions are by means of a custum function

PS. Probably need a custum function, cuz this needs to be applied to 2000+
lines in an excel spreadsheet.

How would i go about this?

Thx for all your hlp!!!!