VBA Code to Auto Fill Text Box

singupalli

New Member
Joined
Apr 19, 2011
Messages
34
Hi

I have a text box in the user form to fill Customers name,

The the previous enteries are stored in the Excel sheet. in column h

when i make a new entry Via the user form, i want the text box Customer name to show the previous entry if already entered/Exists, if not the new name will be typed

Please anyone
 
yes Noorie

I can do that,

But then if there is a new customer, i have to inuput that name in the list first to reflect the same in the combo box,

Want to avoid others to use the main data sheet, all they use is only the user Form.
 
Upvote 0

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
It's quite straightforward to find out if a user has entered a new customer and add it to the list on the workbook.

I can 't post any code right now because I don't know how you currently have things set up.
 
Upvote 0
Hi Singupalli,

I suggest please add a listbox in your user form and fill the same in textbox_change event. This will subsequently fill the list box as you enter any name and tell you if the name has already been entered in Sheet1's H column.

Private Sub TextBox1_Change()
Me.ListBox1.Clear
For Each i In Sheet1.Range(Range(Sheets("Sheet1").Range("H1"), Sheets("Sheet1"). _
Range("H65336").End(xlUp)).Address)
If Mid(i.Value, 1, Len(TextBox1.Text)) = TextBox1.Text Then
Me.ListBox1.AddItem i.Value
End If
Next
End Sub


Regards,
Kunal Shrivastava
 
Upvote 0
Hi Singupalli,
I suggest you to add a list box in your user form that will fill itself in change event of Text box and suggest you will the similar name alredy exixts in H column.
Private Sub TextBox1_Change()
Me.ListBox1.Clear
For Each i In Sheet1.Range(Range(Sheets("Sheet1").Range("H1"), Sheets("Sheet1"). _
Range("H65336").End(xlUp)).Address)
If Mid(i.Value, 1, Len(TextBox1.Text)) = TextBox1.Text Then
Me.ListBox1.AddItem i.Value
End If
Next
End Sub
 
Upvote 0
Please use the below code to make the textbox case in sensitive:
Private Sub TextBox1_Change()
Me.ListBox1.Clear
For Each i In Sheet1.Range(Range(Sheets("Sheet1").Range("H1"), Sheets("Sheet1"). _
Range("H65336").End(xlUp)).Address)
If UCase(Mid(i.Value, 1, Len(TextBox1.Text))) = UCASE(TextBox1.Text) Then
Me.ListBox1.AddItem i.Value
End If
Next
End Sub
 
Upvote 0
Hi Kunal

This works,

But there is an issue , the List box (existing name when popped up, and i add the new invoice details, it does not add the List box name.(Customer name in the data sheet.

my txt box is Cstname, this records in the data
and when i add new name its ok.

Private Sub TxtCstname_Change()
Me.ListBox1.Clear
For Each i In Sheets("Inventory").Range(Range(Sheets("Inventory").Range("M1"), Sheets("Inventory"). _
Range("M65336").End(xlUp)).Address)
If UCase(Mid(i.Value, 1, Len(TxtCstname.Value))) = UCase(TxtCstname.Value) Then
Me.ListBox1.AddItem i.Value
End If
Next
End Sub
 
Upvote 0
<HR style="BACKGROUND-COLOR: #ffffff; COLOR: #ffffff" SIZE=1> Hi Singupalli

Will this this do- you double click on the listbox names that pops up and the one selected gets loaded in Cstname text box.

Regards,
Kunal Shrivastava
 
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,730
Members
452,939
Latest member
WCrawford

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