LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default Spliting Numbers from a Text string

On Sun, 2 Mar 2008 23:46:08 -0800 (PST), Bernd P wrote:

Hello Ron,

IMHO it is a nice and robust approach to take the UDF regexpreplace as
a "black box" and then to call it (may it be from a worksheet or from
within VBA) with:

=regexpreplace(A1,"^05 (.+) PM" & REPT(" ([-+]?\d*\.?\d*)",7) &
"$","$1")

I have no problem to accept a better fitting regular expression here
but I would not even seek for a most efficient solution in VBA. If
efficiency is an issue (in terms of runtime) I would do the
preprocessing with sed or perl...

Regards,
Bernd


Be that as it may, the OP was looking for a VBA solution. Rick's previously
posted solution is quite effective. Both of our regex solutions take about
fifty (50) times as long to extract the first number after the PM.

Longre's Regex.Mid function, part of the morefunc.xll add-in, runs about twice
as fast as either of ours.

I see you've adapted yours to include both positive and negative numbers, but
it still will work only with date code of 05 and time code of PM.

I agree the Regex solutions are simpler to implement for complicated
extractions.
--ron


 
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
Spliting and combing text down rows in Excel 2007 Glenn in London Excel Discussion (Misc queries) 1 August 17th 09 10:16 PM
extract numbers from text string thomsonpa New Users to Excel 4 December 17th 07 11:02 AM
Formula Text String: Formatting Text and Numbers? dj479794 Excel Discussion (Misc queries) 5 June 30th 07 12:19 AM
Spliting 1 Text field into 3 Janet BN Excel Discussion (Misc queries) 4 February 5th 07 12:36 AM
spliting text sungen99[_86_] Excel Programming 2 May 2nd 06 02:33 PM


All times are GMT +1. The time now is 09:09 AM.

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"