I am building a VBA search function across 3 product sheets (one at a time) for determining the next available size of packaging for a part (my attached example is available here VBA match 4 conditional values at once with Select Case. ).
The search is based on 4 input criteria (length, width, height and mass) and returns the record containing the next largest dimensions across each of these values (being >= to the input values).
The combined part volume or aggregate measurements are not a decision criteria. The product sheets need to remain clean and be update-able by users.
I'm looking for the output to be similar to this example http://www.youtube.com/watch?v=QOxhRSCfHaw ("Excel VBA Loop to Find Records Matching Search Criteria") where a matching row is copied and pasted to the search page.
I have setup a (non-VBA) drop-down combobox with a data validation list (Sheet Directory) for the the search page which should activate the chosen worksheet. (thus allowing users to add new product sheets without modifying VBA code).
I am unclear on the best way to manage this sheet activation in VBA and then the procedure for looping through the variables and only return records which meet all of the criteria at once. Any record containing any value not meeting the search condition would not be considered a match.
The inputs:
[TABLE="class: grid, width: 200"]
<tbody>[TR]
[TD]Length[/TD]
[TD]Width[/TD]
[TD]Height[/TD]
[TD]Mass[/TD]
[/TR]
[TR]
[TD]240[/TD]
[TD]33[/TD]
[TD]18[/TD]
[TD]160[/TD]
[/TR]
</tbody>[/TABLE]
Would match a row containing:
[TABLE="class: grid, width: 200"]
<tbody>[TR]
[TD]Length[/TD]
[TD]Width [/TD]
[TD]Height[/TD]
[TD]Mass[/TD]
[/TR]
[TR]
[TD]250.5[/TD]
[TD]35.40[/TD]
[TD]20[/TD]
[TD]187.4[/TD]
[/TR]
</tbody>[/TABLE]
But not be a match for:
[TABLE="class: grid, width: 200"]
<tbody>[TR]
[TD]Length[/TD]
[TD]Width [/TD]
[TD]Height[/TD]
[TD]Mass[/TD]
[/TR]
[TR]
[TD]250.5[/TD]
[TD]35.40[/TD]
[TD]20[/TD]
[TD]150[/TD]
[/TR]
</tbody>[/TABLE]
The procedure I have so far is possibly declaring a multidimensional array for the L,W,H,M column variables and creating a conditional operator of >= all "L,W,H,M" input values. Can I simplify things with a Select Case statement ? Or Select Case Is ?
Sub findpackage()
Dim sheet As String
Range("B3").Value = ComboBox1
sheet = ComboBox1.Value
Worksheets(sheet).Activate
Dim length As Double
Dim height As Double
Dim width As Double
Dim mass As Double
(Declare Array)?
(Select Case Arguments)?
End Sub
Am I barking up the right tree?
Any help would be greatly appreciated!
The search is based on 4 input criteria (length, width, height and mass) and returns the record containing the next largest dimensions across each of these values (being >= to the input values).
The combined part volume or aggregate measurements are not a decision criteria. The product sheets need to remain clean and be update-able by users.
I'm looking for the output to be similar to this example http://www.youtube.com/watch?v=QOxhRSCfHaw ("Excel VBA Loop to Find Records Matching Search Criteria") where a matching row is copied and pasted to the search page.
I have setup a (non-VBA) drop-down combobox with a data validation list (Sheet Directory) for the the search page which should activate the chosen worksheet. (thus allowing users to add new product sheets without modifying VBA code).
I am unclear on the best way to manage this sheet activation in VBA and then the procedure for looping through the variables and only return records which meet all of the criteria at once. Any record containing any value not meeting the search condition would not be considered a match.
The inputs:
[TABLE="class: grid, width: 200"]
<tbody>[TR]
[TD]Length[/TD]
[TD]Width[/TD]
[TD]Height[/TD]
[TD]Mass[/TD]
[/TR]
[TR]
[TD]240[/TD]
[TD]33[/TD]
[TD]18[/TD]
[TD]160[/TD]
[/TR]
</tbody>[/TABLE]
Would match a row containing:
[TABLE="class: grid, width: 200"]
<tbody>[TR]
[TD]Length[/TD]
[TD]Width [/TD]
[TD]Height[/TD]
[TD]Mass[/TD]
[/TR]
[TR]
[TD]250.5[/TD]
[TD]35.40[/TD]
[TD]20[/TD]
[TD]187.4[/TD]
[/TR]
</tbody>[/TABLE]
But not be a match for:
[TABLE="class: grid, width: 200"]
<tbody>[TR]
[TD]Length[/TD]
[TD]Width [/TD]
[TD]Height[/TD]
[TD]Mass[/TD]
[/TR]
[TR]
[TD]250.5[/TD]
[TD]35.40[/TD]
[TD]20[/TD]
[TD]150[/TD]
[/TR]
</tbody>[/TABLE]
The procedure I have so far is possibly declaring a multidimensional array for the L,W,H,M column variables and creating a conditional operator of >= all "L,W,H,M" input values. Can I simplify things with a Select Case statement ? Or Select Case Is ?
Sub findpackage()
Dim sheet As String
Range("B3").Value = ComboBox1
sheet = ComboBox1.Value
Worksheets(sheet).Activate
Dim length As Double
Dim height As Double
Dim width As Double
Dim mass As Double
(Declare Array)?
(Select Case Arguments)?
End Sub
Am I barking up the right tree?
Any help would be greatly appreciated!