Match Function(Code modification)

  • Thread starter Todd Huttenstine\(Remote\)
  • Start date
T

Todd Huttenstine\(Remote\)

Hey guys,

If Application.CountIf(.Range("IV1:IV100"), "Add Stat Name Here") > 0 Then
Range("area22").Interior.ColorIndex =
Range("IV1").Interior.ColorIndex
Else
Range("area22").Interior.ColorIndex = 2
End If

Above is a working code that will color a Named Range of cells a specified
color if the value "Productivity" is found in Range ("IV1:IV100"). In this
example the named range is "area22" and the specified color is associated
with the variable "Range("IV1").Interior.ColorIndex". Also in this example
the Value "Productivity is located in cell A4. If the value "Productivity"
is not found in Range ("IV1:IV100"), then Range "area22" will be shaded
color 2.

In the above example, in order for the code to work, you must specify what
value to look for in Range ("IV1:IV100"). Instead, what I would like is for
the code to look in Range ("IV1:IV100") and if it finds the value of cell
A4, then color Range "area22" the variable
"Range("IV1").Interior.ColorIndex". If it does not find the value, then
color Range "area22" color 2.


Thank you


Todd Huttenstine
 
N

Nigel

Todd, try this

If Application.CountIf(Range("IV1:IV100"), Range("A4")) > 0 Then
Range("area22").Interior.ColorIndex = Range("B1").Interior.ColorIndex
Else
Range("area22").Interior.ColorIndex = 2
End If

Cheers
N
 
N

Nigel

correction in line 2 to read "IV1" not "B1"


If Application.CountIf(Range("IV1:IV100"), Range("A4")) > 0 Then
Range("area22").Interior.ColorIndex = Range("IV1").Interior.ColorIndex
Else
Range("area22").Interior.ColorIndex = 2
End If


Nigel said:
Todd, try this

If Application.CountIf(Range("IV1:IV100"), Range("A4")) > 0 Then
Range("area22").Interior.ColorIndex = Range("B1").Interior.ColorIndex
Else
Range("area22").Interior.ColorIndex = 2
End If

Cheers
N







----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption
=---
 
T

Todd Huttenstine\(Remote\)

thanx

it worked.


Nigel said:
correction in line 2 to read "IV1" not "B1"


If Application.CountIf(Range("IV1:IV100"), Range("A4")) > 0 Then
Range("area22").Interior.ColorIndex = Range("IV1").Interior.ColorIndex
Else
Range("area22").Interior.ColorIndex = 2
End If


Encryption
=---




----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption
=---
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Creating a loop from my code 3
Need help changing Range 3
Syntax Error 3
Color Sort 3
Pivot Table Code - Is there a better way? 2
Adding code 1
Adding code 5
Code arrangement 3

Top