Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > VBA / Office Integration > Excel > Run a formula of a cell only once


Reply
 
Thread Tools Display Modes
  #1  
Old 08-27-2008, 07:38 PM
saneen saneen is offline
Newcomer
 
Join Date: Aug 2008
Posts: 23
Default Run a formula of a cell only once


I have a formula set for a group of cells which captures the current system date and time at various intervals of time. I have set the Now() function to achieve this. But the problem i am facing is that every time the time is changed all the cells are updated. I would want the formula to run only once. i.e once executed it should not run again. Is this possible anyway. Thanks in Advance.
EDIT: Note i have some macros which run when i open the workbook.
Reply With Quote
  #2  
Old 08-27-2008, 07:53 PM
gpraceman's Avatar
gpraceman gpraceman is offline
Contributor

* Expert *
 
Join Date: Sep 2002
Location: Highlands Ranch, CO
Posts: 556
Default

You can create a module level boolean variable to help ensure that it only runs once. If the value is False, then run the formula and set the variable to True; otherwise skip the formula.
__________________
Awana Grand Prix and Pinewood Derby racing - Where a child, an adult and a small block of wood combine for a lot of fun and memories.
Reply With Quote
  #3  
Old 08-28-2008, 06:02 AM
saneen saneen is offline
Newcomer
 
Join Date: Aug 2008
Posts: 23
Default

I wonder if i can get away by not creating a macro. I want to do a formula only. Is it possible.
Reply With Quote
  #4  
Old 08-28-2008, 06:22 AM
Colin Legg's Avatar
Colin Legg Colin Legg is offline
Out Of Office

Retired Moderator
* Expert *
 
Join Date: Mar 2005
Location: London, UK
Posts: 3,398
Default

The Now() function is volatile. It updates pretty much whenever you do something with the worksheet. To stop it updating you would have to copy and pastespecial values which would effectively remove the formula and leave the result. You could use VBA to do this for you.
__________________
RAD Excel Blog
Reply With Quote
  #5  
Old 08-28-2008, 07:00 AM
gpraceman's Avatar
gpraceman gpraceman is offline
Contributor

* Expert *
 
Join Date: Sep 2002
Location: Highlands Ranch, CO
Posts: 556
Default

Duh, you were talking about a forumula. I was thinking that you were running a chunk of code. Yeah, what Colin L said.
__________________
Awana Grand Prix and Pinewood Derby racing - Where a child, an adult and a small block of wood combine for a lot of fun and memories.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->