Refer to the cell in which a function is entered.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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
 
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
 

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

Back
Top