Solved

update other prog. while running VB-Excel macro

Posted on 1998-08-17
5
152 Views
Last Modified: 2010-04-30
In an Excel spread sheet I have a cell which pulls a value (changing number) from another program with the formula:

"=View|tagname!'x1'"

Now I want to copy the actual value into another cell every 5 minutes (everytime a new cell, because the value is changeing) so that I can see the result after some 3 hours. I wrote a macro in
Visual Basic, but with that macro I do have the same value in each cell, because the other programm is not delivering the new value. Or is Excel not looking for the new one?

Question: How can I copy a changing value from one cell into anther automatically?
0
Comment
Question by:question4
  • 3
  • 2
5 Comments
 
LVL 1

Expert Comment

by:jeffcameron
ID: 1429485
use the calculate event of the worksheet and the copy method of the range object.  keep track of the next location in a global variable.  
0
 

Author Comment

by:question4
ID: 1429486
I think I used the calculate method already. Here is my
VB programm:

Const spalte = 2

Sub test()

    For zeile = 5 To 10
    Range("B3").Select
    ActiveCell.FormulaR1C1 = "=View|tagname!'x1'"
    ActiveWorkbook.RefreshAll
    Selection.Copy
    ActiveCell.Clear
    Range(Cells(zeile, spalte), Cells(zeile, spalte)).Select
    Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
        False, Transpose:=False
    Range("B4").Select
    Selection.Copy
    Next zeile
   
End Sub

So how would I use the calculate event according to your answer?
Please clearify. Thank you.
0
 

Author Comment

by:question4
ID: 1429487
see above
0
 
LVL 1

Accepted Solution

by:
jeffcameron earned 100 total points
ID: 1429488
' use this routine for the control
Dim PauseTime, Start, Finish, TotalTime

sub Run
      PauseTime = 5 * 60      ' Set duration.
      Start = Timer      ' Set start time.
      Do While Timer < Start + PauseTime
            DoEvents      ' Yield to other processes.
      Loop
      
        Worksheets("SheetName").Calculate
end sub

' use one of these events to get the value when it changes with ' the previoes code to pull the value when it changes

' these can be found in the sheet objects by double clicking on ' the sheet from the VBA project window

Private Sub Worksheet_Calculate()

' something like this
Range("B3").copy Range("B4")

End Sub

Private Sub Worksheet_Change(ByVal Target As Excel.Range)

End Sub

' if your other program is not delivering you the correct answer ' though then it will not work
0
 

Author Comment

by:question4
ID: 1429489
Thanks!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now