Hi all
I'm trying to find a way to create an alternative to a longwinded INDEX/MATCH/COUNTA formula in VBA, in the hope that the VBA simplifies the process, or at least has a more straightforward way of achieving the same end. The requirement of the formula is to lookup all entries in a database that match the chosen lookup value (from a drop down list) and then return the customer with the matching entry, with all matching entries being listed. At present the results are displayed within the worksheet in descending rows. But i'm thinking that this whole process would be just as easy to set up in a UserForm.
The database looks like the below, with the exception that the 'product group' cells are merged (so only one of each type):
[TABLE="width: 500"]
<tbody>[TR]
[TD][/TD]
[TD]Product Group A[/TD]
[TD]Product Group A[/TD]
[TD]Product Group A[/TD]
[TD]Product Group B[/TD]
[TD]Product Group B[/TD]
[TD]Product Group B[/TD]
[TD]Product Group C[/TD]
[TD]Product Group C[/TD]
[TD]Product Group C[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Variant A1[/TD]
[TD]Variant A2[/TD]
[TD]Variant A3[/TD]
[TD]Variant B1[/TD]
[TD]Variant B2[/TD]
[TD]Variant B3[/TD]
[TD]Variant C1[/TD]
[TD]Variant C2[/TD]
[TD]Variant C3[/TD]
[/TR]
[TR]
[TD]Customer A[/TD]
[TD]Yes[/TD]
[TD]Yes[/TD]
[TD]Yes[/TD]
[TD][/TD]
[TD]Yes[/TD]
[TD][/TD]
[TD]Yes[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Customer B[/TD]
[TD][/TD]
[TD]Yes[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]Yes[/TD]
[TD][/TD]
[TD]Yes[/TD]
[TD]Yes[/TD]
[/TR]
[TR]
[TD]Customer C[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]Yes[/TD]
[TD][/TD]
[TD]Yes[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Customer D[/TD]
[TD]Yes[/TD]
[TD]Yes[/TD]
[TD]Yes[/TD]
[TD]Yes[/TD]
[TD][/TD]
[TD]Yes[/TD]
[TD][/TD]
[TD]Yes[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
My formula is as follows:
=IFERROR(OFFSET(OtherDB!$A$3,SMALL(IF(OFFSET(OtherDB!$A$3,1,INDEX(OtherList!$A$2:$A$161,MATCH($C$3,ProdListOther,0)),COUNTA(OtherDB!$A$4:$A$13),1)<>"",ROW(OtherDB!$A$4:$A$13),""),ROW()-ROW($F$3))-3,0),"")
'OtherDB!' is the database, 'OtherList!' is the crib list the makes the search work.
Can anybody point me in the right direction at all in terms of a workable VBA solution?
Thanks in advance!
I'm trying to find a way to create an alternative to a longwinded INDEX/MATCH/COUNTA formula in VBA, in the hope that the VBA simplifies the process, or at least has a more straightforward way of achieving the same end. The requirement of the formula is to lookup all entries in a database that match the chosen lookup value (from a drop down list) and then return the customer with the matching entry, with all matching entries being listed. At present the results are displayed within the worksheet in descending rows. But i'm thinking that this whole process would be just as easy to set up in a UserForm.
The database looks like the below, with the exception that the 'product group' cells are merged (so only one of each type):
[TABLE="width: 500"]
<tbody>[TR]
[TD][/TD]
[TD]Product Group A[/TD]
[TD]Product Group A[/TD]
[TD]Product Group A[/TD]
[TD]Product Group B[/TD]
[TD]Product Group B[/TD]
[TD]Product Group B[/TD]
[TD]Product Group C[/TD]
[TD]Product Group C[/TD]
[TD]Product Group C[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Variant A1[/TD]
[TD]Variant A2[/TD]
[TD]Variant A3[/TD]
[TD]Variant B1[/TD]
[TD]Variant B2[/TD]
[TD]Variant B3[/TD]
[TD]Variant C1[/TD]
[TD]Variant C2[/TD]
[TD]Variant C3[/TD]
[/TR]
[TR]
[TD]Customer A[/TD]
[TD]Yes[/TD]
[TD]Yes[/TD]
[TD]Yes[/TD]
[TD][/TD]
[TD]Yes[/TD]
[TD][/TD]
[TD]Yes[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Customer B[/TD]
[TD][/TD]
[TD]Yes[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]Yes[/TD]
[TD][/TD]
[TD]Yes[/TD]
[TD]Yes[/TD]
[/TR]
[TR]
[TD]Customer C[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]Yes[/TD]
[TD][/TD]
[TD]Yes[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Customer D[/TD]
[TD]Yes[/TD]
[TD]Yes[/TD]
[TD]Yes[/TD]
[TD]Yes[/TD]
[TD][/TD]
[TD]Yes[/TD]
[TD][/TD]
[TD]Yes[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
My formula is as follows:
=IFERROR(OFFSET(OtherDB!$A$3,SMALL(IF(OFFSET(OtherDB!$A$3,1,INDEX(OtherList!$A$2:$A$161,MATCH($C$3,ProdListOther,0)),COUNTA(OtherDB!$A$4:$A$13),1)<>"",ROW(OtherDB!$A$4:$A$13),""),ROW()-ROW($F$3))-3,0),"")
'OtherDB!' is the database, 'OtherList!' is the crib list the makes the search work.
Can anybody point me in the right direction at all in terms of a workable VBA solution?
Thanks in advance!