Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Syntax for variable search

I've narrowed it down with this change:

Dim a, b, c As String

a = "("
b = "?????"
c = ")"
FindWhat = a & b & c

...and changed the line:

Pos = InStr(ActiveCell.Value, a)

But then I'll have to know how many digits in the number beforehand.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Syntax for variable search

See my suggestion.

Regards,
Tom Ogilvy

"brym" wrote in message
...
I've narrowed it down with this change:

Dim a, b, c As String

a = "("
b = "?????"
c = ")"
FindWhat = a & b & c

..and changed the line:

Pos = InStr(ActiveCell.Value, a)

But then I'll have to know how many digits in the number beforehand.




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 179
Default Syntax for variable search

brym

Try this sub

Sub FindPar()

Dim FndRng As Range
Dim FirstAdd As String
Dim StartPos As Long
Dim EndPos As Long
Dim i As Long
Dim AllNumbers As Boolean
Const WhatStart As String = "("
Const WhatEnd As String = ")"

Set FndRng = Cells.Find(WhatStart, , , xlPart)

If Not FndRng Is Nothing Then
FirstAdd = FndRng.Address
Do
StartPos = InStr(1, FndRng.Value, WhatStart)
EndPos = InStr(StartPos, FndRng.Value, WhatEnd)
If EndPos 0 Then
AllNumbers = True
For i = StartPos + 1 To EndPos - 1
If Not IsNumeric(Mid(FndRng.Value, i, 1)) Then
AllNumbers = False
Exit For
End If
Next i

If AllNumbers Then
FndRng.Characters(StartPos, EndPos - StartPos + 1).Font.Bold
= True
End If
End If
Set FndRng = Cells.FindNext(FndRng)
Loop Until FndRng.Address = FirstAdd
End If

End Sub

--
Dick Kusleika
MVP - Excel
www.dicks-clicks.com
Post all replies to the newsgroup.

"brym" wrote in message
...
I've narrowed it down with this change:

Dim a, b, c As String

a = "("
b = "?????"
c = ")"
FindWhat = a & b & c

..and changed the line:

Pos = InStr(ActiveCell.Value, a)

But then I'll have to know how many digits in the number beforehand.




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
Syntax for 'search' in Horizontal range? XL2007 ker_01 Excel Worksheet Functions 2 October 6th 09 04:11 PM
Deleting a range of rows based on a variable; syntax error Babymech Excel Discussion (Misc queries) 3 January 16th 09 06:19 PM
macro syntax for selecting variable range Matt Excel Discussion (Misc queries) 1 October 31st 07 07:13 PM
VBA Syntax for using a variable in a worksheet function xjetjockey Excel Discussion (Misc queries) 3 January 9th 07 04:23 AM
Syntax for variable search Don Guillett[_4_] Excel Programming 0 August 6th 03 04:35 PM


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