Dear all members,

I am following the "Tutorial - Use MSCOMM with a serial device" here http://www.excelforum.com/excel-prog...al-device.html

I got an error "Sub or Function not defined" and the debugger highlights in yellow "Private Sub Getdata()"

Here is my code
Private Sub MSComm21_OnComm()
If Worksheets("SerialPort").MSComm21.CommEvent = comEvReceive Then
Call Getdata
End If

End Sub
Sub OpenPort()

'Open the COM Port with the relevant settings

Worksheets("SerialPort").MSComm21.CommPort = 5 'Number of com port we are intended to use
Worksheets("SerialPort").MSComm21.Settings = "9600,n,8,1"
Worksheets("SerialPort").MSComm21.RThreshold = 1 'By setting it to '1' we are telling Excel to fire the 'OnComm' code whenever data is received from the serial port.
Worksheets("SerialPort").MSComm21.InBufferSize = 4096
Worksheets("SerialPort").MSComm21.PortOpen = True

End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Not Intersect(Target, Columns("A:A")) Is Nothing Then

If Target.Value = "" Then

Call OpenPort

End If
End If

Application.EnableEvents = True

End Sub

Private Sub Getdata()

Dim MyData As String
Wokrsheets("SerialPort").MSComm21.InputLen = 0

MyData = Worksheets("SerialPort").MSComm21.Input
ActiveCell.Value = MyData

MyData = ""

Worksheets("SerialPort").MSComm21.PortOpen = False

End Sub
Possible cause: I don't add Reference on Getdata but the thing is I don't find any reference (Tools>References>?????)

Any help is much appreciated!!

Cheers.