POV-Ray : Newsgroups : povray.off-topic : Using Excel as a 3D engine : Re: Using Excel as a 3D engine Server Time
11 Oct 2024 01:25:15 EDT (-0400)
  Re: Using Excel as a 3D engine  
From: Phil Cook
Date: 13 Mar 2008 08:03:29
Message: <op.t7yg83rac3xi7v@news.povray.org>
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

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.