Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Determine if values are contained within Range 1

Status
Not open for further replies.

PRUSA

Technical User
Sep 23, 2004
35
US
Hi All,

I'm a beginner to VBA, but honestly am starting to enjoy it alot. I'm messing around with this one macro, but I find myself using way too many IF statements.

I'm just wondering if anyone knew how to condense the code for the following:

Sheet1
A1= "ABC"
A8= "DEF"

Sheet2
A3 = "DEF"
A9 = "XYZ"

This is what I wanna do. In sheet1 I have two values. I am trying to write a macro that will tell me whether the cells in sheet2 A3 or A9 contain those values, and if so make teh cells that contain the valid value(s) green, and the cell that don't cotain the values make red.

I can do this with if statments, but the code is getting long. I'm not familiar with working with Ranging or Array, and for some reason I think I would need to use them.

If someone could please help me I would appreciate it.

Thanks In Advance.
 
You can use named ranges and macro code, or it might be simpler just to use conditional formatting.

If you want to go the macro route, here's the high-level logic:
For each cell in range
if cell.value = "ABC" then
<change text font color>
end if
next cell

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top