input box, auto enter

Huffy

New Member
Joined
Dec 10, 2009
Messages
2
Hi there,

Is there a way to have an automatic carriage return once a limit is reached for an input box?
Ex. Once 8 characters have been entered in the input box, there is an automatic carriage return, thus hitting OK.

This is to be used for scanning barcodes and would simplify the process if OK is pressed automatically.

Thanks all,

Huffy
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
It can be done in a userform because it has a Change Event.
Perhaps something like this :-
Code:
'===========================================================
'- USERFORM CODE :  TEXTBOX CHANGE EVENT
'- TRANSFER VALUE TO WORKSHEET AFTER 8 CHARACTERS
'- Brian Baulsom April 2010
'===========================================================
Private Sub TextBox1_Change()
    Dim MyLen As Integer    ' textbox text length
    '-------------------------------------------------------
    '- CHECK TEXT LENGTH
    MyLen = Len(TextBox1.Value)
    If MyLen = 8 Then
        Beep
        '---------------------------------------------------
        '- TEXTBOX CONTENTS TO THE WORKSHEET
        Range("A1").Value = TextBox1.Value
        '---------------------------------------------------
        '- CLEAR THE TEXTBOX
        TextBox1.Value = ""
        '---------------------------------------------------
    End If
    '-------------------------------------------------------
End Sub
'============================================================
 
Upvote 0

Forum statistics

Threads
1,216,100
Messages
6,128,825
Members
449,470
Latest member
Subhash Chand

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