Quote Originally Posted by lesleyperk View Post
My VBA application gets external data from instruments and puts them into consecutive rows until macro is stopped. However after completing the first few rows, the screen is no longer updated and the circular busy symbol is displayed so it looks as if the macro has stopped working. However, if I force the macro to stop, all the data acquired has been put into the spreadsheet. How can I stop this 'sleep' mode or whatever it is, from activating?
Quote Originally Posted by Steffen Thomsen View Post
What does your code look like?
Do While Not lb_stop
If Timer >= li_time + li_interval Then
Application.ScreenUpdating = False 'do not update screen til whole row ready
li_time = Int(Timer)
If li_start_time = 0 Then 'First time
li_start_time = li_time
End If
Range("A" & Rowno).Select
ActiveCell.Value = li_time - li_start_time
'Execute the requests for readings
lngError = GoOne(Handle(0)) 'labjack 1
lngError = GoOne(Handle(1)) 'labjack 2

'Get the Timer Values (this returns the time between rising edges):
'Engine RPM
lngError = GetResult(Handle(1), LJ_ioGET_TIMER, 0, dResult) 'RPM
If lngError <> 0 Then
Err.Raise lngError + 50000
ElseIf dResult = 0 Then
'Just ignore
Else
dResult = 1 / (dResult * (1 / LJClock))
Range("B" & Rowno).Select
ActiveCell.Value = Round(dResult, 0)
End If

'Fuel flow rate
lngError = GetResult(Handle(1), LJ_ioGET_TIMER, 1, dResult) 'Fuel Flow Rate
If lngError <> 0 Then
Err.Raise lngError + 50000
ElseIf dResult = 0 Then
'Just ignore
Else
dResult = 1 / (dResult * (1 / LJClock))
Range("U" & Rowno).Select
ActiveCell.Value = Round(dResult, 0)
End If

'Read pressures
For Ch = 4 To 12
lngError = GetResult(Handle(0), LJ_ioGET_AIN, Ch, dResult)
dResult = dResult * l_psi_pressure(Ch - 4) / 5 'multiple result by max psi/bar then divide by 5 (max volts)
Range(l_column_pressure(Ch - 4) & Rowno).Select
ActiveCell.Value = Round(dResult, 1)
Next


'LabJack 2 on board temp
lngError = GetResult(Handle(1), LJ_ioGET_AIN, 14, CJTempK)
If lngError <> 0 Then Err.Raise lngError + 50000
LJ_Temp = CJTempK - 273.5

For Ch = 0 To 5 'Temperatures
'Get the analog input voltage readings.
lngError = GetResult(Handle(l_unit_temp(Ch) - 1), LJ_ioGET_AIN, l_channel_temp(Ch), dResult)
If lngError <> 0 Then
' Err.Raise lngError + 50000
Else
lngError = TCVoltsToTemp(LJ_ttK, dblAIN0, CJTempK, dResult)
dResult = dResult - li_KConstant
Range(l_column_temp(Ch) & Rowno).Select
ActiveCell.Value = Round(dResult, 0)
End If
Next
‘All data now in row so update screen
Application.ScreenUpdating = True 'show new row

Rows(Rowno - 1 & ":" & Rowno - 1).Select
With Selection.Interior 'Remove shading previous Row
.Pattern = xlNone
.TintAndShade = 0
.PatternTintAndShade = 0
End With

Rows(Rowno & ":" & Rowno).Select 'Shade current row
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 65535
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Rowno = Rowno + 1


End If
If li_time - li_start_time > 240 Then
lb_stop = True
End If
Loop

Have made bold the code relating to the display.