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:

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
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
 
Upvote 0
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?
 
Upvote 0

Forum statistics

Threads
1,214,926
Messages
6,122,305
Members
449,079
Latest member
juggernaut24

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
Back
Top