dmwa
09-13-2016, 04:33 AM
Im doing a little data logging, A1 is an external reference and takes a few seconds to connect. once connected and it reads the variable numerical value and the script runs fine and logs every change of value in A1. problem is when first opening the workbook the script goes into a type mismatch error because the value of A1 as not updated yet and reads #N/A. I tried using a check box to run the script but it only logs the first change and seems to not log any further changes. any help would be greatly appreciated
Private Sub Worksheet_Calculate()
Static oldval
If Range("A1").Value <> oldval Then
oldval = Range("A1").Value
Range("A3").EntireRow.Insert
Range("A1:C1").Select
Selection.Copy
Range("A3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Range("A31").EntireRow.Delete
End If
End Sub
Private Sub Worksheet_Calculate()
Static oldval
If Range("A1").Value <> oldval Then
oldval = Range("A1").Value
Range("A3").EntireRow.Insert
Range("A1:C1").Select
Selection.Copy
Range("A3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Range("A31").EntireRow.Delete
End If
End Sub