I am very new to Excel VBA so please be gentle. I have some code that is triggered on a button click. However, I want it to be triggered on a change event (basically that a text box contains information) like another set of code I have. What I need help with is sort of a merge of code here. I need the fuction of the 1st set of code below to be triggered like the second set of code.
Just so you know I am scanning in a barcode and and I want it to find the barcode in the correct row then increase the next cell to the right by 1. Then the value clears in the form so I can scan again.
If you need me to upload a file, I can certainly do that. Just tell me to.
Private Sub btn_Add_Click()
Dim TargetCell As Range
If WorksheetFunction.CountIf(Sheets("Main").Columns(4), TextBox1.Value) = 1 Then
Set TargetCell = Sheets("Main").Columns(4).Find(TextBox1.Value, , xlValues, xlWhole).Offset(0, 1)
TargetCell.Value = TargetCell.Value + 1
TextBox1.Value = ""
MsgBox "Item Not Found"
Dim IsActive As Boolean
If UserForm2.TextBox1.Text = "" Then Exit Sub
If Application.CountIf(.Range("D:D"), UserForm2.TextBox1.Text) = 0 Then
.Range("D" & .Rows.Count).End(xlUp)(2).Value = UserForm2.TextBox1.Text
MsgBox "That Item Already Exists"
UserForm2.TextBox1.Text = ""
IsActive = False