Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Calculate Event

good morning,

I have a big excel spread with a lot of different vba functions and
volitale functions

I would just like to add function that in a specified cell every second the
value of the cell is increasing by 1.

My problem is that as soon I add the function


Private Sub Worksheet_Calculate()
Application.OnTime Now + TimeValue("00:00:01"), "zahl"
End Sub


Public i

Sub zahl()
i = i + 1
Cells(5, 5) = i
End Sub

The spreadsheet is not updating every second but maybe every millisecond

Is there a way that the Worksheet_Calculate() is only trigger if the
specified cell is changed ??

Best Regards
Ciao
Martin
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Calculate Event


Hi Martin,

with Private Sub Worksheet_Change(ByVal Target As Range)
you cant use
If Target.Address = "$A$10" Then '<<<< change cell

to accomplish what you are looking for ...

HTH
Carim


--
Carim
------------------------------------------------------------------------
Carim's Profile: http://www.excelforum.com/member.php...o&userid=33259
View this thread: http://www.excelforum.com/showthread...hreadid=531291

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Calculate Event

The problem is using Calculate, as it fires a new Ontime each time. Why not
just run a macro from workbook open that fires Ontime, and that macro resets
the Ontime call. C hip shows how at http://www.cpearson.com/excel/ontime.htm

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Martin Bauer" wrote in message
0...
good morning,

I have a big excel spread with a lot of different vba functions and
volitale functions

I would just like to add function that in a specified cell every second

the
value of the cell is increasing by 1.

My problem is that as soon I add the function


Private Sub Worksheet_Calculate()
Application.OnTime Now + TimeValue("00:00:01"), "zahl"
End Sub


Public i

Sub zahl()
i = i + 1
Cells(5, 5) = i
End Sub

The spreadsheet is not updating every second but maybe every millisecond

Is there a way that the Worksheet_Calculate() is only trigger if the
specified cell is changed ??

Best Regards
Ciao
Martin



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 718
Default Calculate Event

You should not use the Calculate Event (which may happen a any time)
You'd rather use Workbook_open to initialize the process.

Paste this in ThisWorkbook code:

'---------------------------------------------
Private Sub Workbook_Open()
zahl
End Sub
'---------------------------------------------

Then paste into a Module:
'----------------------------------
Sub zahl()
Static i
i = i + 1
Cells(5, 5).Value = i
' Reinit timer
Application.OnTime Now + TimeValue("00:00:01"), "zahl"
End Sub
'------------------------------------

HTH
--
AP



You should start your (time) event handler from Workbook_open event

"Martin Bauer" a écrit dans le message de
0...
good morning,

I have a big excel spread with a lot of different vba functions and
volitale functions

I would just like to add function that in a specified cell every second

the
value of the cell is increasing by 1.

My problem is that as soon I add the function


Private Sub Worksheet_Calculate()
Application.OnTime Now + TimeValue("00:00:01"), "zahl"
End Sub


Public i

Sub zahl()
i = i + 1
Cells(5, 5) = i
End Sub

The spreadsheet is not updating every second but maybe every millisecond

Is there a way that the Worksheet_Calculate() is only trigger if the
specified cell is changed ??

Best Regards
Ciao
Martin



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Calculate Event

"Ardus Petus" wrote in
:

This was the solution - it is working extremly well

Thanks again
Ciao

You should not use the Calculate Event (which may happen a any time)
You'd rather use Workbook_open to initialize the process.

Paste this in ThisWorkbook code:

'---------------------------------------------
Private Sub Workbook_Open()
zahl
End Sub
'---------------------------------------------

Then paste into a Module:
'----------------------------------
Sub zahl()
Static i
i = i + 1
Cells(5, 5).Value = i
' Reinit timer
Application.OnTime Now + TimeValue("00:00:01"), "zahl"
End Sub
'------------------------------------

HTH
--
AP



You should start your (time) event handler from Workbook_open event

"Martin Bauer" a écrit dans le message de
0...
good morning,

I have a big excel spread with a lot of different vba functions and
volitale functions

I would just like to add function that in a specified cell every
second

the
value of the cell is increasing by 1.

My problem is that as soon I add the function


Private Sub Worksheet_Calculate()
Application.OnTime Now + TimeValue("00:00:01"), "zahl"
End Sub


Public i

Sub zahl()
i = i + 1
Cells(5, 5) = i
End Sub

The spreadsheet is not updating every second but maybe every
millisecond

Is there a way that the Worksheet_Calculate() is only trigger if the
specified cell is changed ??

Best Regards
Ciao
Martin







  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Calculate Event

"Bob Phillips" wrote in
:

The problem is using Calculate, as it fires a new Ontime each time.
Why not just run a macro from workbook open that fires Ontime, and
that macro resets the Ontime call. C hip shows how at
http://www.cpearson.com/excel/ontime.htm


Indeed I solved it this way

Thanks

Ciao
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Calculate Event

Carim wrote in
:


Hi Martin,

with Private Sub Worksheet_Change(ByVal Target As Range)
you cant use
If Target.Address = "$A$10" Then '<<<< change cell

to accomplish what you are looking for ...

HTH
Carim


hi martin,

I solved it via worksheet_open

Cheers
thanks
M
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Change event and calculate event Antje Excel Programming 1 March 29th 05 09:03 PM
AFTER Calculate Event PosseJohn Excel Programming 4 January 16th 05 07:31 PM
Whorksheet Calculate Event Q John Excel Programming 2 December 11th 04 05:43 PM
Worksheet Calculate Event Gustavo[_4_] Excel Programming 2 January 14th 04 09:00 PM


All times are GMT +1. The time now is 12:16 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"