I have created an excel form to count inventory using scan barcode to text box. now I have to click button to add new data after scanned and would like to change by auto insert data instead of press the button. Would you please suggest on how to coding? Thank you.
Here is the current command.
Private Sub cmdInsert_Click()
If Len(Trim(Me.txtData1.Value)) = 0 Then
MsgBox "Please fill Data1", vbCritical
Exit Sub
End If
If Len(Trim(Me.txtData2.Value)) = 0 Then
MsgBox "Please fill Data2", vbCritical
Exit Sub
End If
Dim sh As Worksheet
Set sh = ThisWorkbook.Sheets("DataEntry")
Dim lastrow As Long
lastrow = Application.WorksheetFunction.CountA(sh.Range("A:A"))
sh.Range("A" & lastrow).Value = Me.txtData1.Value
sh.Range("B" & lastrow).Value = Me.txtData2.Value
sh.Range("C" & lastrow).Value = Me.txtData3.Value
sh.Range("D" & lastrow).Value = Me.txtData4.Value
Call clear_data
Call ShowData
End Sub
1