|
|
And lo on Thu, 13 Mar 2008 12:23:47 -0000, Invisible <voi### [at] devnull> did
spake, saying:
>>> Now, if you call a macro with a cell range as its argument, how does
>>> that work?
>> Not sure what you mean, you can pass arguments on in the normal mann
er
>> i.e. Call Macro1(MyRange) from within another macro, or do you mean h
ow
>> do I pass what you've selected in the worksheet to the macro you're
>> running? Which would be
>> ActiveWorksheet.ActiveCell or better ActiveWorksheet.Selection
>
> Actually I meant "how do I make it so I can write =MyMacro(A4:C9) in
a
> cell formula and have it actually work properly?"
You can't with macros you need to use a function instead so add a module
to your worksheet and try
Public Function Temperature(Degrees As Double, ConvertType)
If ConvertType = "C" Then
Temperature = (Degrees - 32) * (5 / 9)
Else
If ConvertType = "F" Then
Temperature = (Degrees / 5 / 9) + 32
Else
Temperature = CVErr(xlErrNA)
End If
End Function
Now go to your worksheet and enter =Temperature(32, "C") and you'll ge
t a 0
--
Phil Cook
--
I once tried to be apathetic, but I just couldn't be bothered
http://flipc.blogspot.com
Post a reply to this message
|
|