Select and Highlight certain cells

forumfinder

New Member
Joined
Dec 9, 2011
Messages
3
Hi All,

I am developing a macro which select certain rows from table and highlight them based on the result. (Green for Okay and Red for Wrong).
The criteria is if lets say "A1" has word "Happy" and "A2" has word "Happy go lucky" then after running macro, "A1" and "A2" gets highlighted by green. Vice versa, if "A2" doesn't have "Happy" then "A1" and "A2" gets highlighted by Red.

e.g.: If Range("A2") contains val(Range("A1")) then
Range("A1:A2").highlight(Green)

something like this....



Please advise me on this.....
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
[SOLVED] Select and Highlight certain cells

Hi all,

since I have some other macros too, I have to use VBA. BTW,
I found a simple code for it.
Code:
        If InStr(1, s2, s1) Then
            ran.Interior.Color = RGB(128, 255, 0)
        Else
            ran.Interior.Color = RGB(255, 0, 0)
        End If

it works fine for me! :cool:
 
Upvote 0

Forum statistics

Threads
1,216,075
Messages
6,128,660
Members
449,462
Latest member
Chislobog

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