ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Syntax for variable search (https://www.excelbanter.com/excel-programming/273698-re-syntax-variable-search.html)

Don Guillett[_4_]

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






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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com