lookup data from a form to a sheet

jinx_uk_98

Board Regular
Joined
Jul 3, 2005
Messages
105
Hi all,

On a form I have 2 textboxs. In textbox1 the user will enter a date and in textbox2 they will enter a value.

What code do I need to attach to a button to lookup up the date from textbox1 (the dates are listed on sheet1 a1:a50) then copy the text from textbox2 in the relevant cell next to the looked up date.

I hope that makes sense, any help greatly appreciated

Kevin
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Hi kevin

Are the dates always going to be in the list A1:A50 ? If so you could use a combobox.

The main problem that I had with this was date format how are the cells in the list formatted (What style of date formatting)?

I've got it working but only when date cells are formatted in a particular way.

Don't know if its of any use.

L
 
Upvote 0
OK, i assumed that the dates in the list are the only ones you want to enter against so i made the first textbox a combobox and sourced the list.

The format of my cells on the sheet is 14/03/2001

In the Userform there are 1Textbox, 1Combobox and a Commandbutton
Its a bit rough but it works.

Private Sub ComboBox1_Change()
ComboBox1.Value = Format(ComboBox1.Text, "DD/MM/YYYY")
End Sub

Private Sub CommandButton1_Click()

Set dtinfo = Sheet1.Range("A1:A50")
With dtinfo
Set cb1 = .Find(Me.ComboBox1.Value, LookIn:=xlValues, LookAt:=xlWhole)
cb1.Offset(0, 1).Value = Me.TextBox1.Value

End With
Unload Me
End Sub

Private Sub UserForm_Initialize()
ComboBox1.Value = Format(ComboBox1.Text, "DD/MM/YYYY")
ComboBox1.Value = ""
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,497
Messages
6,172,640
Members
452,467
Latest member
colelkay

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