Return data to userform via two criterias

LearningEX

Board Regular
Joined
Mar 13, 2015
Messages
200
hi all, the picture below is what i want to achieve. i want to be able to select a date from the date picker, then select a truck for that date as i may have two trucks out on that date, then based on the two criteria, i then want the information returned to the listboxes like the picture.

VBA Code:
Private Sub txtTourDate_AfterUpdate()
100: 'Check to see if value exists
101: If WorksheetFunction.CountIf(Sheet12.Range("C:C"), Me.txtTourDate.Value) = 0 Then
102: MsgBox "This date is Not Found"
103: Me.txtTourDate.Value = ""
104: Exit Sub
105: End If
106: 'Lookup values based on first control
107: With Me
108: .CboTrucks = Application.WorksheetFunction.VLookup(CLng(Me.txtTourDate), Sheet12.Range("Lookup"), 2, 0)
109: .Label3 = Application.WorksheetFunction.VLookup(CLng(Me.txtTourDate), Sheet12.Range("Lookup"), 14, 0)
110: .Label6 = Application.WorksheetFunction.VLookup(CLng(Me.txtTourDate), Sheet12.Range("Lookup"), 20, 0)
111: .Label10 = Application.WorksheetFunction.VLookup(CLng(Me.txtTourDate), Sheet12.Range("Lookup"), 23, 0)
112: .Label13 = Application.WorksheetFunction.VLookup(CLng(Me.txtTourDate), Sheet12.Range("Lookup"), 26, 0)
113:
114: End With
End Sub
for excel.PNG
VBA Code:
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.

Forum statistics

Threads
1,148,006
Messages
5,744,315
Members
423,861
Latest member
Ka3EeM

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