View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Don Guillett[_4_] Don Guillett[_4_] is offline
external usenet poster
 
Posts: 2,337
Default Syntax for variable search

untested but why not just find "("

--
Don Guillett
SalesAid Software
Granite Shoals, TX

"brym" wrote in message
...
Hi!
This macro I would like to enhance to be more flexible. But before I start
doing (trying) that, I need some help re. the searching syntax.
There's no problem finding a specified part of a string and change the
properties. However, (as I expected) the SQL syntax doesn't work with the
FindWhat var.
Can anyone help me with the syntax so I may find/isolate any number
surrounded by brackets, e.g (98765) or (1234567).

Sub PartOfString()

Dim Pos, Lngt As Integer
Dim FindWhat As String

On Error Resume Next

FindWhat = "Perfect" ' Should be "(" and any whole number and ")"

Cells.Find(what:=FindWhat, after:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False).Activate

Lngt = Len(FindWhat)
Pos = InStr(ActiveCell.Value, FindWhat)

With ActiveCell.Characters(Start:=Pos, Length:=Lngt).Font
.Name = "Arial"
.FontStyle = "Normal"
End With

End Sub

OR MAYBE - another way to do the trick !?

Thanks in advance

Regards Birger