View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Excel_Rookie[_2_] Excel_Rookie[_2_] is offline
external usenet poster
 
Posts: 2
Default Trying to highlight cells that have the same value as the acti

Thanks that did it.....

"Gord Dibben" wrote:

Remove the first line and replace with this.

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, _
ByVal Target As Range)

Cut the entire set of code and paste into ThisWorkbook module, not a sheet
module.


Gord Dibben MS Excel MVP

On Thu, 11 Jun 2009 16:28:01 -0700, Excel_Rookie
wrote:

How can I do it for the entire workbook ? I don't want to paste the code into
every worksheet within the workboob if I can have it at the workbook level.

thanks

"Jacob Skaria" wrote:

If you are new to VBA set the Security level to low/medium in
(Tools|Macro|Security). Right click on the sheet tab on which you would like
to have this highligtion and click on 'View Code'. Paste the below code.

I have defined the applicable range as E1:E100 and the range in Col G as
G1:G8. You can change this as per your requirement..

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim rngTemp As Range
Set rngTemp = Range("E1:E100")
rngTemp.Interior.ColorIndex = xlNone
If Not Application.Intersect(Target, Range("G1:G8")) Is Nothing Then
If Target.Value < "" Then
For Each cell In rngTemp
If Target.Value = cell.Value Then
cell.Interior.Color = vbYellow
End If
Next
End If
End If
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Excel_Rookie" wrote:

I want to be able to highlight all the cells that have the same text as the
active cell?

So if I'm on G8 and that cell has the word Apples then I want to highlight
all the cells in the E1:E100 range that have Apples in the cell.