Hi and thank you all for a great forum and resource. I find myself at age 60 excited by new things to learn in Excel. I am less than a novice with VB and am currently working on some code (developed with the assistance of one of our programmers). The code captures the output from a microbalance's serial port and writes the output to the currently selected cell (Excel 2007). In order to make the sheet efficient in the fashion it's most likely to be used I'd like to increment the pointer down one row to the next cell in preparation to accept the next entry. Mice are fine but why bother if you have to...
Here is the entire code as it currently exists but I'm assuming the additioanl code would need to be added following the activecell.activate line highlighted here in red.
Private Sub XMCommCRC1_OnComm()
Static sInput As String
Dim sTerminator As String
Dim Buffer As Variant
' Branch according to the CommEvent property.
Select Case XMCommCRC1.CommEvent
Case XMCOMM_EV_RECEIVE
Buffer = XMCommCRC1.InputData ' Use Input property for MSComm
sInput = sInput & Buffer
If Worksheets("Settings").Range("Terminator") = "CR/LF" Then
sTerminator = vbCrLf
Else
sTerminator = vbCr
End If
If Right$(sInput, Len(sTerminator)) = sTerminator Then
XMCommCRC1.PortOpen = False
sInput = Left$(sInput, Len(sInput) - Len(sTerminator))
Dim a As Integer
Dim b As String
For a = 1 To Len(sInput)
If (Mid(sInput, a, 1)) = "g" Then
b = Mid(sInput, 1, a - 1)
ActiveCell.Value = CDbl(b)
ActiveCell.Activate
Exit For
End If
Next a
sInput = ""
End If
End Select
End Sub
Any assistance or suggestions are greatly appreciated!
Bookmarks