Hi guys,
I've searched high and low for a solution to my specific problem, but to no avail. Hence this post.
I am developing an Excel database of drivers and the trucks they drove. These entries are being made via a userform throughout the month as they use the truck. The basic table as captured in Excel looks like this:
<tbody>
[TD="width: 64"]Month[/TD]
[TD="width: 64"]Truck[/TD]
</tbody>
I then have a userform that will be used for basic reporting (this is where my question originated from). On that userform one can select the driver name in one combobox, and the month in another combobox. After that a button is clicked to load the unique trucks that the given driver drove with during that month.
Any given driver will drive with at most three trucks in any given month, but can use any of those three trucks multiple times.
I therefore need VBA code that will get all the unique trucks a specific driver drove with, and save them in Variable1, Variable2 and Variable3. The data type for this can be string or variant. If a driver only drove with one truck only Variable1 will have data in it. It is fine if the other variables are declared - they will just be NULL value and will not result in anything.
So, for example - if driver John is selected, with month March, the unique trucks driven would be Truck C and Truck B, which can be saved in Variable1 and Variable2 (this will then be transfered to textboxes and used for other functions).
The reason this became complicated for me is that John drove more than once with Truck B (could be true for any other truck or all of them). But since that truck is a unique value I only need to know that the truck was driven by John for that specific month. A driver can therefore use any truck multiple times during any given month.
I hope I got my problem across. Please feel free to ask questions if anything is unclear.
I have tried code for this, but I feel so far from the mark that I am not going to post it.
Thanks in advance!
I've searched high and low for a solution to my specific problem, but to no avail. Hence this post.
I am developing an Excel database of drivers and the trucks they drove. These entries are being made via a userform throughout the month as they use the truck. The basic table as captured in Excel looks like this:
Name | ||
James | January | Truck A |
Jock | February | Truck B |
John | March | Truck C |
Keith | January | Truck B |
James | February | Truck A |
Jock | March | Truck C |
John | January | Truck C |
Keith | February | Truck B |
John | March | Truck B |
Jock | January | Truck C |
John | February | Truck C |
Keith | March | Truck B |
James | January | Truck C |
Jock | February | Truck A |
John | March | Truck B |
<tbody>
[TD="width: 64"]Month[/TD]
[TD="width: 64"]Truck[/TD]
</tbody>
I then have a userform that will be used for basic reporting (this is where my question originated from). On that userform one can select the driver name in one combobox, and the month in another combobox. After that a button is clicked to load the unique trucks that the given driver drove with during that month.
Any given driver will drive with at most three trucks in any given month, but can use any of those three trucks multiple times.
I therefore need VBA code that will get all the unique trucks a specific driver drove with, and save them in Variable1, Variable2 and Variable3. The data type for this can be string or variant. If a driver only drove with one truck only Variable1 will have data in it. It is fine if the other variables are declared - they will just be NULL value and will not result in anything.
So, for example - if driver John is selected, with month March, the unique trucks driven would be Truck C and Truck B, which can be saved in Variable1 and Variable2 (this will then be transfered to textboxes and used for other functions).
The reason this became complicated for me is that John drove more than once with Truck B (could be true for any other truck or all of them). But since that truck is a unique value I only need to know that the truck was driven by John for that specific month. A driver can therefore use any truck multiple times during any given month.
I hope I got my problem across. Please feel free to ask questions if anything is unclear.
I have tried code for this, but I feel so far from the mark that I am not going to post it.
Thanks in advance!