Parsing information out of a cell

  • Thread starter Thread starter Sean
  • Start date Start date
S

Sean

Hi

I have a horseracing database. Within one of the fields
(RaceTitle) it stipulates the class of race. For example
it might say "McDonalds Selling Stakes CLASS G (O-90)"

I would either like to update the cell or create a cell
which to show only the class of the race. In the above
example the RaceTitle would now read G (as this is the
class of the race).

I need to write something that says look for the word
class, ignore the blank space at the end of the word but
copy the letter that appears immediately after the space.

Any ideas?

thanks
 
Perfect application of regular expressions!

Make sure to include a reference to "Microsoft VBScript Regular Expressions
5.5" in your project.


Public Function ExtractRaceClass(strRaceDescription As String) As String
'i.e. ExtractRaceClass( "McDonalds Selling Stakes CLASS G (O-90)") = "G"

' If no match is found, a copy of strRaceDescription is returned
unchanged.

With New VBScript_RegExp_55.RegExp
.Pattern = "(.*CLASS)([^\w]*)(\w+)(.*)"
.IgnoreCase = True
ExtractRaceClass = .Replace(strRaceDescription, "$3")
End With
End Function
 
Hi Sean,

If you aren't familiar with using VBA functions, you
should be able to also use the following:

Mid([RaceTitle],InStr([RaceTitle],"CLASS")+6,1)

-Ted Allen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top