Application.Caller returning error 2023

wasabi

New Member
Joined
Apr 12, 2010
Messages
28
I'm trying to use Application.Caller to alter the background of the cell that called the function, however it always returns an invalid value. However, I'm hardly a VBA expert, so I might be doing this entirely wrong.

Code:
Dim R as Range
R = Application.Caller
What I do later isn't really relevant since it fails on this block. If I try to debug, Caller has an "error 2023" value.
 

shg

MrExcel MVP
Joined
May 7, 2008
Messages
21,721
Office Version
2010
Platform
Windows
A range is an object variable, so it requires Set:

Code:
Set R = Application.Caller
However, you could more easily just use ThisCell (see Help).

However (again), a UDF (a function called from a worksheet) can't do anything (with some arcane exceptions, of which this isn't one) but return a result to the cell in which it appears.
 

Forum statistics

Threads
1,085,149
Messages
5,381,992
Members
401,764
Latest member
pzippel

Some videos you may like

This Week's Hot Topics

Top