Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 117
Default Highlight the exact value

Hi, the macro below is curtesy of this ng.

The only problem is that if a value to hightlight
is say, a '7' it will hightlight '17' I presume that
this is because there is a '7' in '17' ...

Can any kind soul alter the code so it highlights
the exact values in the range please as I may have
to hightlight as many as 20 values in 18,000

cheers, ste

Sub colourrowsin()
Dim i As Long
Dim Lookupvalue
Dim c As Variant
'Clear the current range
Range("A3:A52").Select
Selection.Interior.ColorIndex = xlNone

For i = 2 To 7 ' Look at values in T2 to T7
Lookupvalue = Cells(i, 20).Value
'{Search A3:A52 for a match to Lookupvalue}
With Range("A3:A52")
Set c = .Find(Lookupvalue)
If Not c Is Nothing Then
'(if match then highlight the cell in range}
Range(c.Address).Select
With Selection.Interior
.ColorIndex = 15
.Pattern = xlSolid
End With
End If
End With
Next

End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Highlight the exact value

Change

Set c = .Find(Lookupvalue)

to

Set c = .FindWhat:=Lookupvalue, LookAt:=xlWhole)


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"ste mac" wrote in message
oups.com...
Hi, the macro below is curtesy of this ng.

The only problem is that if a value to hightlight
is say, a '7' it will hightlight '17' I presume that
this is because there is a '7' in '17' ...

Can any kind soul alter the code so it highlights
the exact values in the range please as I may have
to hightlight as many as 20 values in 18,000

cheers, ste

Sub colourrowsin()
Dim i As Long
Dim Lookupvalue
Dim c As Variant
'Clear the current range
Range("A3:A52").Select
Selection.Interior.ColorIndex = xlNone

For i = 2 To 7 ' Look at values in T2 to T7
Lookupvalue = Cells(i, 20).Value
'{Search A3:A52 for a match to Lookupvalue}
With Range("A3:A52")
Set c = .Find(Lookupvalue)
If Not c Is Nothing Then
'(if match then highlight the cell in range}
Range(c.Address).Select
With Selection.Interior
.ColorIndex = 15
.Pattern = xlSolid
End With
End If
End With
Next

End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 117
Default Highlight the exact value

Bob, you are the man
!
absolutely bang on...cheers dude..

ste

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
Highlight exact match in column and count mgbcab Excel Discussion (Misc queries) 2 June 2nd 10 02:29 PM
Highlight exact match in column mgbcab Excel Discussion (Misc queries) 2 June 2nd 10 01:22 PM
how to highlight more related cells if cell highlight Jon Excel Discussion (Misc queries) 5 December 21st 08 01:06 PM
Routine to find exact Row matches in Col1 Col2 Col3 but exact offsetting numbers in Col4 [email protected] Excel Discussion (Misc queries) 0 June 11th 08 11:30 PM
Highlight cells with ctrl-click but only un-highlight one cell hagan Excel Discussion (Misc queries) 5 May 27th 05 06:45 PM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"