Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Anthony Slater
 
Posts: n/a
Default

Dave

Thats excellent m8.

You've really helped me out as you help out a lot of others on this
excellent source of Excel information.

Have a wonderful day coz thanks to you, I will

"Dave Peterson" wrote:

I'd use a User Defined Function:

Option Explicit
Function GetNumbers(rng As Range) As Variant

Dim iCtr As Long
Dim myStr As String
Dim myTestStr As String
Dim FoundIt As Boolean

Set rng = rng(1)
myStr = rng.Value

FoundIt = False
For iCtr = 1 To Len(myStr)
myTestStr = Mid(myStr, iCtr, 8)
If myTestStr Like "39######" Then
FoundIt = True
Exit For
End If
Next iCtr

If FoundIt = True Then
GetNumbers = "'" & myTestStr 'for Text values
'or
GetNumbers = myTestStr 'for real number values
Else
GetNumbers = ""
End If

End Function

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Short course:

Open your workbook.
Hit alt-f11 to get to the VBE (where macros/UDF's live)
hit ctrl-R to view the project explorer
Find your workbook.
should look like: VBAProject (yourfilename.xls)

right click on the project name
Insert, then Module
You should see the code window pop up on the right hand side

Paste the code in there.

Now go back to excel.
Into a test cell and type:
=GetNumbers(a1)

Anthony Slater wrote:

Hi

I've been given a text file with one particular colum that is 'free text
entrry'

There is an 8 figure serial number that always starts with 39 (39xxxxxx).
However, as this has been typed in by various people, it can appear anywhere
with in the rest of the text such as: -
fred blogs 39123456 12/02/04
12.02.04 blogs fred, 39123456
fred, 39123456 12-feb-04

As many people are typing information in, some people use different methods
(commas, spaces, slashes, no spaces, no commas etc)

The only thing that is common is that the 39 figue is always 8 characters long

How can I extract the 39xxxxxx number?

TIA


--

Dave Peterson

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sort or Filter option? Mcobra41 Excel Worksheet Functions 3 February 23rd 05 07:22 PM
Extracting the number from a text Venkatesh V Excel Discussion (Misc queries) 1 February 23rd 05 04:27 PM
Defining a number in a cell by text then subtracting it by the tex Crowraine Excel Worksheet Functions 1 December 16th 04 07:49 AM
Formatting a cell as "text" in the number catagory. Ed Excel Worksheet Functions 3 December 7th 04 07:12 PM
GET.CELL Biff Excel Worksheet Functions 2 November 24th 04 07:16 PM


All times are GMT +1. The time now is 12:36 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"