Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default Remove Non-Numerics from String

On Wed, 9 May 2007 13:14:01 -0700, ExcelMonkey
wrote:

Norman, quick question for you. I want to incorporate what you provided with
another function I pulled from the newsgroup which splits an excel fomula by
operator. The first function is in example one below. Problem is, that it
does not preserve the absolute references of the cells ("$"). How do I
change the pattern do incorporate the "$"?


What do you mean when you write "does not preserve the absolute references of
the cells ("$")"?

I don't see it stripping out the "$"'s from cell references, at least in simple
formulas.



Example 1:
Function Parser(FormulaStr As String) As Variant
Dim Parsed() As String
Dim objRegExp As Object
Dim objMatchCollection As Object
Dim sPattern As String
Dim i As Long

sPattern =
"(('[\s\S]*?'!\w+)|(\([\s\S]*?\))|([^-+*/^<=]+))([-+*/^<][<=]?|$)"


Set objRegExp = CreateObject("VBScript.RegExp")
objRegExp.IgnoreCase = True
objRegExp.Global = True
objRegExp.MultiLine = True

objRegExp.Pattern = sPattern
If objRegExp.Test(FormulaStr) = True Then
Set objMatchCollection = objRegExp.Execute(FormulaStr)
ReDim Parsed(1 To objMatchCollection.Count, 1 To 2)
For i = 1 To objMatchCollection.Count
Parsed(i, 1) = objMatchCollection(i - 1).submatches(0)
Debug.Print Parsed(i, 1)
Parsed(i, 2) = objMatchCollection(i - 1).submatches(4)
Debug.Print Parsed(i, 2)
Next i
End If

Parser = Parsed
End Function


--ron
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
remove text from string Todd Excel Worksheet Functions 3 May 25th 06 11:10 PM
Remove specified value from string Todd Huttenstine Excel Programming 1 January 31st 06 07:32 PM
Remove specified string from value Todd Huttenstine Excel Programming 1 January 31st 06 05:13 PM
Remove specified value from string Todd Huttenstine Excel Programming 2 January 31st 06 04:48 PM
Remove the last letter from a string! Mannyluk Excel Programming 1 March 21st 05 03:45 PM


All times are GMT +1. The time now is 03:42 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"