View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
joel joel is offline
external usenet poster
 
Posts: 9,101
Default Pull Out Numbers From String

This code works

Function ExtractNumber(target As Range) As Long

ExtractNumberString = target
Do While (Left(ExtractNumberString, 1) < "0") Or _
(Left(ExtractNumberString, 1) "9")
ExtractNumberString = Mid(ExtractNumberString, 2)
Loop

ExtractNumber = Val(ExtractNumberString)

End Function

"Curious" wrote:

This column is comment. Numbers mixed with text in the cells. They
look like

Statue of liberty 12345 statue of liberty
12345 statue of liberty statue of liberty
statue of liberty statue of liberty 12345

The number (product order code) could be anywhere.

How do I pull out the numbers by formula or by VB code?

Thanks in advance.

HZ