Refer to the cell in which a function is entered.

R

Rob

My function points to a range, and I want it to count all the cells in the range that are the same colour as the cell in which the function is entered. How can I refer to the cell
Thanks in advanc
Ro

Function CountSameColour(MyRange as excel.range
for each cell in myrang
if cell.interior.colorindex={{{{{{{{this cell}}}}}}}}.interior.colorindex the
countsamecolour=countsamecolour+
end i
nex
End Function
 
T

Tom Ogilvy

Application.Caller

--
Regards,
Tom Ogilvy

Rob said:
My function points to a range, and I want it to count all the cells in the
range that are the same colour as the cell in which the function is entered.
How can I refer to the cell?
Thanks in advance
Rob

Function CountSameColour(MyRange as excel.range)
for each cell in myrange
if cell.interior.colorindex={{{{{{{{this
cell}}}}}}}}.interior.colorindex then
 
F

Frank Kabel

Hi
use
application.caller
for this

Note: The return value won't change if you only change the
format of this cell (this won't force a re-calculation)
-----Original Message-----
My function points to a range, and I want it to count all
the cells in the range that are the same colour as the
cell in which the function is entered. How can I refer to
the cell?
Thanks in advance
Rob

Function CountSameColour(MyRange as excel.range)
for each cell in myrange
if cell.interior.colorindex={{{{{{{{this
cell}}}}}}}}.interior.colorindex then
 
Top