POV-Ray : Newsgroups : povray.off-topic : Using Excel as a 3D engine Server Time
11 Oct 2024 05:22:07 EDT (-0400)
  Using Excel as a 3D engine (Message 41 to 45 of 45)  
<<< Previous 10 Messages Goto Initial 10 Messages
From: Phil Cook
Subject: Re: Using Excel as a 3D engine
Date: 13 Mar 2008 06:20:29
Message: <op.t7ychevkc3xi7v@news.povray.org>
And lo on Wed, 12 Mar 2008 14:41:20 -0000, Invisible <voi### [at] devnull> did
  

spake, saying:

> scott wrote:
>>> And this stuff isn't really documented anywhere.
>>  Rubbish!
>>  Try looking up "range" or "cells" or "worksheet" in the object brows
er  

>> and reading the help.
>
> What is the "object browser"?
>
>> Worksheets(1).Cells(1, 1).Value = 24
>>  ActiveSheet.Cells(2, 1).Formula = "=Sum(B1:B5)"
>>  How could it be any more clear what to do?
>
> That seems reasonably clear.

or even MyValue = Worksheets("Results").Range("A1:D5").Value

> 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 manner  

i.e. Call Macro1(MyRange) from within another macro, or do you mean how 
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

so the date function could be

Sub InsertDate()
On Error Goto Handler
ActiveWorksheet.ActiveCell.Value = Format(Date, "Medium Date")
Exit Sub
Handler: MsgBox ("No cell selected")
End Sub

Depends on what you're exactly trying to do though, if you're trying to 
 

ensure that everytime a sheet is accessed a date/time stamp is appended 
to  

a list on a sheet then

Sub AddStamp()
NoOfEntries = Worksheets("Date").UsedRange.Rows.Count
Worksheets("Date").Cells(NoOfEntries + 1, 1).Value = Format(Date, "Med
ium  

Date")
End Sub

Just stick the word "Date" in A1 on the sheet "Date" then hide the sheet
  

then run it at startup from ThisWorkbook with

Private Sub Workbook_Open()
Call AddStamp()
End Sub

It also has the advantage that UsedRange counts every cell that *has* be
en  

used, so if some sneaky soul just deletes the date (rather then the enti
re  

row) it'll be left blank when the next stamp is placed.

>> Or, as Gilles said, record a macro and then look at the code (and the
  

>> help related to the code generated) - a nice trick for learning how t
o  

>> do lots of things in Excel (like creating charts, changing borders,  

>> sorting etc).
>
> I'm still at the level of not really knowing how to work the VB editor
,  

> and not understanding basic VB syntax constructs...

Recording stuff and picking it apart really helps, just pick the command
  

and hit F1 for a meaning and example.

-- 

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

From: Invisible
Subject: Re: Using Excel as a 3D engine
Date: 13 Mar 2008 07:23:48
Message: <47d91cd4$1@news.povray.org>
>> 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 manner 
> i.e. Call Macro1(MyRange) from within another macro, or do you mean how 
> 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?"

-- 
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*


Post a reply to this message

From: Nicolas Alvarez
Subject: Re: Using Excel as a 3D engine
Date: 13 Mar 2008 08:00:45
Message: <47d9257d$1@news.povray.org>

>>> 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 manner 
>> i.e. Call Macro1(MyRange) from within another macro, or do you mean 
>> how 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?"
> 

Ah, so you want to convert your macro into a formula function? I would 
look at the manual for you... but I uninstalled M$ Office a while ago :)


Post a reply to this message

From: Phil Cook
Subject: Re: Using Excel as a 3D engine
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

From: Orchid XP v7
Subject: Re: Using Excel as a 3D engine
Date: 13 Mar 2008 13:10:21
Message: <47d96e0d$1@news.povray.org>
Darren New wrote:

> Yeah. I don't need a loop to call SUM(A1:A10) either. :-)

Right. So I picked a bad example. :-P

-- 
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*


Post a reply to this message

<<< Previous 10 Messages Goto Initial 10 Messages

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