VBA Userform Code to use enter/carriage return to trigger code

flyingmonkeyofdoom

Board Regular
Joined
Sep 22, 2010
Messages
161
I wonder if any one can help wi the below code.

What should happen is that via a userform a barcode is scanned and entered into a textbox.
The scanner is set up to move to the next cell down (Return); which i am hoping to use as a trigger to do the below and start running some other code.

Current as soon as anything (letters, numbers etc) is entered the code starts and doesn't let the information be entered.
I need it to enter the information and when, and only, the infomration and ENTER/carriage return is used to implement the code below

Code:
Private Sub TextBox1_Change()    
If TextBox1.EnterKeyBehavior = True Then
        Range("F1") = UserForm3.TextBox1.Value
        Call Pivot_test
    End If
End Sub
 
Last edited:

Some videos you may like

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple

Haluk

Rules Violation
Joined
Oct 26, 2002
Messages
1,075
See the below code if it helps you;

Code:
Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
    If KeyCode = 13 Then
        MsgBox "You pressed ENTER key"
        '.......
        'You can place your code here
        '.......
    End If
End Sub
 

flyingmonkeyofdoom

Board Regular
Joined
Sep 22, 2010
Messages
161
when i scan the first letter being entered starts the code and doesn't wait for it all to be entered

Is there anyway of doing this?
The scanner should scan in a 11 digit alphanumeric string and then move to the line below

is the above the best code to use or should i be looking at using something else?
 

Watch MrExcel Video

Forum statistics

Threads
1,122,719
Messages
5,597,736
Members
414,170
Latest member
Mdm

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top