J
joejohnsonatl45
OK, I have looked everywhere, and I cannot find the answer to what must
be a
simple question; how do I support ranges and individual cells with the
same
function? In the way that I can put a function in a cell that is
"=SUM(E10,F10,G10,G14:G21)" I also want to be able to pass the same
type of
data into a user defined function of my own.
So far, I have found two function declarations that work well:
Public Function CellsVar(ParamArray InRange() As Variant)
and
Public Function CellsRange(InRange As Range)
The CellsVar form works as long as individual cells are comma
separated. The
second form, CellsRange, works just fine with a single range delimited
with
a colon. However, I have not been able to find a form that allows both.
Going back to the example above with the sum function, how do I declare
the
function so as to support both? I am hopeful that the result keeps the
simplicity of the code within the function, whic resembles the
following:
For Each cell In InRange
blah
blah
blah
Next cell
Thanks in advance for your help!! I cannot figure out why the answer is
so
elusive. This seems like Excel programming 101, and should appear
somewhere in the docs....
be a
simple question; how do I support ranges and individual cells with the
same
function? In the way that I can put a function in a cell that is
"=SUM(E10,F10,G10,G14:G21)" I also want to be able to pass the same
type of
data into a user defined function of my own.
So far, I have found two function declarations that work well:
Public Function CellsVar(ParamArray InRange() As Variant)
and
Public Function CellsRange(InRange As Range)
The CellsVar form works as long as individual cells are comma
separated. The
second form, CellsRange, works just fine with a single range delimited
with
a colon. However, I have not been able to find a form that allows both.
Going back to the example above with the sum function, how do I declare
the
function so as to support both? I am hopeful that the result keeps the
simplicity of the code within the function, whic resembles the
following:
For Each cell In InRange
blah
blah
blah
Next cell
Thanks in advance for your help!! I cannot figure out why the answer is
so
elusive. This seems like Excel programming 101, and should appear
somewhere in the docs....