Hey guys new to this but I'm trying.
So im using excel as an OPC client through RSLinks paste special. I am copying data from the plc and moving it down when the PLC tells excel to (ie when a value goes high copy and paste values down a few lines).
So i have a macro to copy and move data down (Not the issue but for reference)
I am pretty happy with the way the macro runs but any suggestions are appreciated.
and some VBA code to run this macro (the issue)
The real issue is with the code to run the macro. The only way i could figure out how to trigger this macro from the plc was too paste special from RSlinks and use this value as a trigger. Because the cell with the imported data is a formula you cannot use a sub change (to my understanding and attempts) and though the old google machine i figured out sub calculate would work. Now this code for sub Worksheet_Calculate() works until you reopen excel where you get
_________________
|run-time error "13":|
|Type mistmatch___|
When debug is enabled it points toward the "If Range("A1").Value = 1 Then" line
Error 13 is the issue that i wish to eliminate and to my knowledge is caused by the if line.
Much Appreciated,
Thomas
Code if needed
Sub Store_Measurments()
'
' Store_Measurments Macro
'
Dim i As Integer
Range("B25").Select
For i = 1 To 23
Selection.EntireRow.Insert , CopyOrigin:=xlFormatFromLeftOrAbove
Next i
Range("B2:H23").Select
Selection.Copy
Range("b25").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
Range("A1").Select
End Sub
Private Sub Worksheet_Calculate()
'On Error Resume Next
If Range("A1").Value = 1 Then
Application.EnableEvents = False
Call Store_Measurments
Application.EnableEvents = True
End If
End Sub
So im using excel as an OPC client through RSLinks paste special. I am copying data from the plc and moving it down when the PLC tells excel to (ie when a value goes high copy and paste values down a few lines).
So i have a macro to copy and move data down (Not the issue but for reference)
I am pretty happy with the way the macro runs but any suggestions are appreciated.
and some VBA code to run this macro (the issue)
The real issue is with the code to run the macro. The only way i could figure out how to trigger this macro from the plc was too paste special from RSlinks and use this value as a trigger. Because the cell with the imported data is a formula you cannot use a sub change (to my understanding and attempts) and though the old google machine i figured out sub calculate would work. Now this code for sub Worksheet_Calculate() works until you reopen excel where you get
_________________
|run-time error "13":|
|Type mistmatch___|
When debug is enabled it points toward the "If Range("A1").Value = 1 Then" line
Error 13 is the issue that i wish to eliminate and to my knowledge is caused by the if line.
Much Appreciated,
Thomas
Code if needed
Sub Store_Measurments()
'
' Store_Measurments Macro
'
Dim i As Integer
Range("B25").Select
For i = 1 To 23
Selection.EntireRow.Insert , CopyOrigin:=xlFormatFromLeftOrAbove
Next i
Range("B2:H23").Select
Selection.Copy
Range("b25").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
Range("A1").Select
End Sub
Private Sub Worksheet_Calculate()
'On Error Resume Next
If Range("A1").Value = 1 Then
Application.EnableEvents = False
Call Store_Measurments
Application.EnableEvents = True
End If
End Sub