Conditional Formatting

M

Michael

I found this great function in
her:http://www.vbaexpress.com/kb/getarticle.php?kb_id=190
It returns the conditional formatting Index color of a cell, however, this
works only if I insert it in a cell, I want to be able to use it inside a
code. What do I have to do?

I basically want to do this:
I want to have the same cell color as the one that has the Conditional
Format set.

For Each TrfcCol In TrfcCol
Trfccol.Interior.ColorIndex=Trfccol.Offset(1,0).Interior.ColorIndex

Next

This is not working and that is why I wanted to return the interior color of
the cell next to the one I want colored.
So I tried this:

Mycolorcell=Trfccol.Offset(1,0).address

FndIndex= ConditionalColor(MyColorCell)


But this gives the following error: ByRef argument type mistmatch

I am lost.....

Michael Arch.
 
J

Joel

The function wants a range, you gave it an address

instead of
Mycolorcell=Trfccol.Offset(1,0).address

FndIndex= ConditionalColor(MyColorCell)

use this
set Mycolorcell=Trfccol.Offset(1,0)
FndIndex= ConditionalColor(MyColorCell)

or
FndIndex= ConditionalColor(Trfccol.Offset(1,0))

this instructio return an address
Mycolorcell=Trfccol.Offset(1,0).address
The address would be something like "C5". This is not a range. A range is
something like Range("C5"). You can set a Range to a new variable with a set
statement


set trfcol = Range("C5")
 

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

Top