Finding a number and coloring the cell he is in

Americanu22

New Member
Joined
Apr 15, 2011
Messages
1
I am using excel 2003 (but an answer in 2007 will be good too because I will ask my company to instal me 2007) .For example: I have a row completed from A1 to D1 with numeric values. If I enter a value
in E1 that corresponds with the value from A1 (just an example it can be B1 or C1 or D1), how can I do so that A1 cell will be coloured and that excell will direct me to it?
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Hi,

I am a relative newbie. The following routine could undoubtedly be done better but it does work. NB It allows for numbers not being unique

This routine assumes that the number you are looking for is entered into A1 and the column containing your list of numbers is from B1 downwards.

Regards,

Alan
Code:
Sub FindAndColor()
    Dim FinalRow As Long
    Dim wsA As Worksheet
    Dim x As Long
    Dim vTarget As Double
    Dim vSeek As Double
    
    Set wsA = Worksheets("Test")
    vSeek = Val(wsA.Cells(1, 1))
    FinalRow = wsA.Cells(Rows.Count, 2).End(xlUp).Row
        For x = 1 To FinalRow
            If vSeek = wsA.Cells(x, 2) Then
            Range("B" & x).Select
                With Selection.Interior
                    .ColorIndex = 6
                    .Pattern = xlSolid
                End With
            End If
        Next x
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,560
Messages
6,179,519
Members
452,921
Latest member
BBQKING

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top