Sampling data every 15 seconds with macros

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Group,
Currently working on a project that requires sampling of data via DDE every
15 seconds, then displaying that data in Excel. Have the data collection done
in the MANUAL routine. Problem is with the 15 second loop, code is below.
This routine is started with a button on the Excel spreadsheet. Currently the
FOR-NEXT loop delays the 15 seconds on the first pass and then just runs
through the next 9 passes with no delay. SLC_TIME is at L6 on the spreadsheet
and formated for hh:mm:ss.

Sub AUTO()
'This routine is for auto operation of data collection. It will
'run the data collection routine MANUAL, the choosen number of
'times

'Gets the number of data points to be collected
data_points = Worksheets("ALCOHOL").Range("L7").Value

'Setup FOR - NEXT loop to cycle through number of data points
For cycles = 1 To data_points

'Gets time from SLC 500 in hours,minute,seconds
slc_time = Worksheets("ALCOHOL").Range("L6").Value

'Delays data collection by one minute from current slc_time
Application.OnTime Now + TimeValue("00:00:15"), "MANUAL"

Next cycles
End Sub

Any ideas on the KISS way to run this every 15 seconds till the total number
of passes are reached?
TIA
Regards
Blank
 
Sub AUTO()
'This routine is for auto operation of data collection. It will
'run the data collection routine MANUAL, the choosen number of
'times

'Gets the number of data points to be collected
data_points = Worksheets("ALCOHOL").Range("L7").Value

'Setup FOR - NEXT loop to cycle through number of data points
For cycles = 1 To data_points

'Gets time from SLC 500 in hours,minute,seconds
slc_time = Worksheets("ALCOHOL").Range("L6").Value

'Delays data collection by one minute from current slc_time
Application.OnTime slc_time + TimeValue("00:00:15"), "MANUAL"

Next cycles
End Sub


TIA
Regards
Blank
 
Back
Top