How Do I.......

ElectricSkywalker

Board Regular
Joined
May 27, 2002
Messages
112
How do I add a lookup into a User Form???
(kinda like a vlookup)

I have created a User Form

In it, (this is a simplified version), I have four fields.

The first is a Text box, txtDate

The second is a Label, lbSales
The third is a Text Box, txtActualSales
The fourth is a Text Box, txtBudgetSales

I want the user to enter in the DATE and the ACTUAL SALES.....but I want the BUDGET SALES to automatically lookup a table on another worksheet....and (based on the Date) automatically display the BUDGET DETAILS for the Date specified.

I have no idea how to go about this??? Can anyone point me in the right direction please.


Thank You
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce

Russell Hauf

MrExcel MVP
Joined
Feb 10, 2002
Messages
1,611
Hard to tell without knowing what format your data is on your worksheet (the data you want to look up). But are you familiar with Application.WorksheetFunction? You could use VLOOKUP if your data is arranged appropriately...

For example,

txtBudgetSales = Application.WorksheetFunction.Vlookup(txtDate.Text, Worksheets("Sheet3").Range("A1:C100"),3,False)

HTH - if not, give an example of your data.

-rh
This message was edited by Russell Hauf on 2002-10-31 17:59
 

ElectricSkywalker

Board Regular
Joined
May 27, 2002
Messages
112
Beautiful Russell.....that is exactly what I have been looking for over the past week :0)
I really love how this forum works.


I guess I am not all that familiar with the Worksheet Function.

So is that what WorksheetFunction is used for....when ever you want to add an excel formulas into VBA....you enter "WorksheetFunction" first?

I have one other question with what you provided though....I have tested my code and it works sweet as. What I have used is:

Private Sub txtCONTBUDG1_Enter()
txtCONTBUDG1 = Application.WorksheetFunction.vlookup(lbSunday.Value, Worksheets("Budget").Range("a1:c20"), 3, False)

End Sub


My Question is.....how do I make the budget data automatically come up....with out having to click on the text box.....as in....as soon as the date is specified, the Budget Data comes up.

Thank You
Greg
 

Russell Hauf

MrExcel MVP
Joined
Feb 10, 2002
Messages
1,611
If your date is being input into the txtDate text box, then just put that same line of code into the AfterUpdate event of txtDate (instead of in the Enter event of the text box you want the value written to).

HTH,

Russell
This message was edited by Russell Hauf on 2002-10-31 19:05
 

Forum statistics

Threads
1,144,768
Messages
5,726,179
Members
422,660
Latest member
mrsteele

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
Top