Solved

update other prog. while running VB-Excel macro

Posted on 1998-08-17
5
149 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
Comment Utility
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
Comment Utility
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
Comment Utility
see above
0
 
LVL 1

Accepted Solution

by:
jeffcameron earned 100 total points
Comment Utility
' 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
Comment Utility
Thanks!
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

763 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

11 Experts available now in Live!

Get 1:1 Help Now