View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Mark VII Mark VII is offline
external usenet poster
 
Posts: 7
Default creating custom function - need to receive a cell address as a par

Hello --

I need to create a custom function that I will use in a formula, and it
needs to take action based on the contents of another cell on another
worksheet in the same workbook. The idea is to get a different from the
formula based on the color of the cell on the other worksheet. Sort of like
this:

Public Function ComputeCount (<cell reference) as integer

if <cell reference.Interior.Color = vbRed then
'* do the math one way
else
'* do the math another way
end if

end Function

While I'm pretty proficient at VBA, I'm just not seeing how to get the
function pointing to the cell of interest on the worksheet of interest. I'm
used to setting an Worksheet object variable to reference a given worksheet
and a Range object variable to reference a given cell (such as in
batch-oriented processing), but I've never tried this in a function to be
used in a formula.

Any suggestions? Thanks in advance,

Mark