deleted: see my next post
deleted: see my next post
Last edited by tony h; 04-19-2010 at 06:59 AM.
click on the * Add Reputation if this was useful or entertaining.
Ok, I have had a bit of a look and I think the code below should do the job.
What you do need to do is make sure that the connection is set with the "enable background refresh" to "off" ie un-ticked.
: on the data tab ... go to connections ... existing connections and pick properties
![]()
Sub GetData2() Dim rng As Range Dim i As Long Dim dte As Date Dim dteNext As Date Dim iMax As Long Dim wkb As Workbook Set wkb = ThisWorkbook dte = Now Set rng = ActiveSheet.Range("M1") iMax = 3 'change this to number of time to loop For i = 1 To iMax wkb.RefreshAll rng = Now '' ''change this block to the actually addresses you need '' rng.Offset(, 1) = ActiveSheet.Range("B3") '1st piece of data rng.Offset(, 2) = ActiveSheet.Range("B15") '2nd piece of data rng.Offset(, 3) = ActiveSheet.Range("B16") '3rd piece of data Set rng = rng.Offset(1) dteNext = dte + TimeSerial(Hour:=0, Minute:=1 * i, Second:=0) 'change this value to number of minutes 'Application.Wait dteNext If i <> iMax Then Do: DoEvents: rng = Now: Loop Until Now >= dteNext Next MsgBox "done" End Sub
Thanks tony h for your huge effort to help. I am now off work until friday due to my shift pattern and so wont be able to try out your new code until then. As you can tell I am no programmer but will let you know how it goes over the weekend.
I would like to thank tony h for supplying this answer to my problem. I am now able to record all my data from the building management system IP addresses onto one excel sheet. I just have one last request if anyone can help, I would like to be able to type in comments on the same sheet when the returned data is out of limits, but when I do this the macro stops working and I have to restart it. Does anyone know a way of getting around this problem. Thanks
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks