POV-Ray : Newsgroups : povray.off-topic : Excel question : Re: Excel question Server Time
3 Sep 2024 11:21:06 EDT (-0400)
  Re: Excel question  
From: Phil Cook v2
Date: 14 Feb 2011 06:08:41
Message: <op.vqv3w3z8mn4jds@phils>
And lo On Sat, 12 Feb 2011 21:19:18 -0000, bart <bar### [at] homeorg> did spake  
thusly:

> On 02/12/2011 06:18 PM, Shay wrote:
>> For instance, I want to enter a value into B1 and have the value from A1
>> added to it. Any help?
>>
> You could try to start with something like this VB macro code for  
> ThisWorkbook object:
>
> Private Sub Workbook_SheetChange(ByVal Sh As Object, _
>          ByVal Source As Range)
>     If (Source.Address = "$B$1" _
>     And Sh.Name = "Sheet1") Then
>       Application.EnableEvents = False
>       Source.Value = Source.Value + Cells(1, 1).Value
>       Application.EnableEvents = True
>     End If
> End Sub
>
> Is there a real need for this, why not to use for example
> simple formula in extra cell "=B1+A1"?

As an aside I'd use a "Worksheet_Change" on the sheet itself and "If Not  
Intersect(Target, Range("B:B")) Is Nothing Then" and "Source.Formula" to  
maintain the added value. Good that you remembered  
"Application.EnableEvents = False" otherwise the scripted change will  
trigger the script again and it's infinite loop time; so easy to forget :-)

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