Right click the sheet tab lable, select "View Code" then paste a copy of the code below to the sheet module. JSW
Sub myColor()
'By Joe Was, 2/2002.
'This code will find the cell(s) colored by the myWeight sub below.
Dim myRowNum As Long
myRowNum = ActiveSheet.UsedRange.Rows.Count
Selection.Select
Do Until Selection.Row = myRowNum + 1
If Selection.Interior.ColorIndex<> xlNone Then
'To select entire row, un-comment below!
'Selection.EntireRow.Select
GoTo mySelect
Else
Selection.Offset(1, 0).Select
End If
Loop
End
mySelect:
End Sub
Sub myWeight()
'By Joe Was, 2/2002.
'This code will find the value entered in A2 on sheet1.
'Change "Worksheets( ) to your sheet number below.
Application.ScreenUpdating = False
With Worksheets(1).Range("A3:A100")
Set c = .Find(Worksheets(1).Range("A2"), LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
c.Interior.ColorIndex = 6
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address<> firstAddress
End If
End With
Application.ScreenUpdating = True
End Sub
You will run this code with a form button or hot-key option. Tools, Macro, Macros, Options then add your hot key letter. The sub's will find and color all the cells that match the find value, the myColor sub can be re-run to find the next colored cell.
You could add code to reset the colored cells to noColor or just don't save the workbook after the cells have been colored?
JSW
This message was edited by Joe Was on 2002-03-01 14:44