LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Syntax for variable search

Sub PartOfString()
Dim rng As Range
Dim firstAddress As String
Set rng = Cells.Find(what:="(*)", after:=Range("A1"), _
LookIn:=xlFormulas, LookAt:=xlWhole, _
SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False)

If Not rng Is Nothing Then
firstAddress = rng.Address
Do
With rng.Characters(Start:=2, _
Length:=Len(rng) - 2).Font
.Name = "Arial"
.FontStyle = "Bold"
End With
Set rng = Cells.FindNext(rng)
If rng Is Nothing Then Exit Do
Loop While rng.Address < firstAddress
End If
End Sub

Assuming you don't want to work on cells like

this cell has (12345) in it

but only cells like

(12345)

--
Regards,
Tom Ogilvy



"brym" wrote in message
...
Hi Tom!

In my first post I changed the FindWhat to "(*)" and xlWhole. Now it only
hits cells containing (number) and moreover only the first 3 letters
are changed to bold.

And no, it will always be in connection with a text.

In my sheets i could have this in a cell:

this is a sample (12345) cell value

I want only (12345) to be e.g. bold. As mentioned in my later post, I can

do
this, IF I know the number of letters I'm searching for (?????). I would
like only the brackets to be the limits.

(Hitting an (abc) is ok. I'll find a solution for that.)

Regards Birger




 
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
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 brym Excel Programming 2 August 6th 03 05:32 PM
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 10:37 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"