LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #11   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 947
Default Help with VBA InStr() function

Here's my attempt at finding the two cell addresses.
There's not a lot of logic here. It just looks at the characters following
the "!" Character.
There may be a better technique. I shortened the string a little.

Returns:

Found: 2
$U$77
$U$85

Sub Demo()
'// = = = = = = = = = =
'// Microsoft VbScript Regular Expressions 5.5
'// = = = = = = = = = =

Dim Re As RegExp
Dim MyEquation As String
Dim AllPositions As MatchCollection
Dim Position As Match

'// Looking for a cell Address:
Const LookFor As String = "![$ 0-9 A-Z]+"

MyEquation = "'P:\[Book.xls]Allo'!$U$77*10-'P:\DMB\[Book.xls]Allo'!$U$85"

Set Re = New RegExp
Re.Pattern = LookFor
Re.IgnoreCase = True
Re.Global = True

If Not Re.Test(MyEquation) Then Exit Sub
Set AllPositions = Re.Execute(MyEquation)
Debug.Print "Found: " & AllPositions.Count

For Each Position In AllPositions ' 0-Indexed
Debug.Print Mid$(Position.Value, 2)
Next Position
End Sub

--
HTH :)
Dana DeLouis
Windows XP & Office 2007

<snip


 
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
Use InStr function in formula? Lee Hunter Excel Worksheet Functions 8 May 8th 23 03:45 AM
is there an equal fxn for 'InStr' in excel. Not Find or Search Clausius Excel Worksheet Functions 3 May 1st 23 03:41 AM
Where is the Instr() function in Excel 2003? chem21 Excel Discussion (Misc queries) 3 October 9th 06 03:49 PM
LINKEDRANGE function - a complement to the PULL function (for getting values from a closed workbook) [email protected] Excel Worksheet Functions 0 September 5th 06 03:44 PM
Emulate Index/Match combo function w/ VBA custom function Spencer Hutton Excel Worksheet Functions 2 May 2nd 05 05:26 PM


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