Textbox

dwarek

Board Regular
Joined
Jul 15, 2016
Messages
79
Hello i would like to know whether there is possibility for a textbox in a userform to rememeber the value which entered previously. For Example if i type INDIGO in textbox 1 and click on command button the value will be passed to the worksheet so next time if i type IN then the word INDIGO should be suggested.Is there any vba code for that.
thanks n advance
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Hi dwarek,

I'm not sure about a TextBox but you could something like the below with a ComboBox and a helper column to store the previous entries...

Code:
Private Sub UserForm_Initialize()

LastRow = Range("A" & Rows.Count).End(xlUp).Row

ComboBox1.RowSource = "A1:A" & LastRow

End Sub

Private Sub CommandButton1_Click()

LastRow = Range("A" & Rows.Count).End(xlUp).Row

Range("A" & LastRow + 1).Value = ComboBox1.Value

Range("A:A").RemoveDuplicates Columns:=1, Header:=xlNo

End Sub

Hope this helps,
Cheers,
Alan.
 
Upvote 0

Forum statistics

Threads
1,215,013
Messages
6,122,690
Members
449,092
Latest member
snoom82

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