How do I get a form to lookup data for 3 different controls? (co.
Hi,
I assume the data in held in a table in a worksheet (as this is not stated
in your query) so something like this will work:
A B C D E F .......
City Age Gender Data
London 24 Female Mary
Paris 39 Male John
London 25 Female Natasha
New York 30 Female Jane
London 24 Male Mark
London 24 Female Nicola
Sub TestLookup(Location As String, Age As Integer, Gender As String)
Dim rng As Range. Dim i as Long, iLastrow as Long
Set rng = Range("A1:I10")
iLastrow = Cells(Rows.Count, "A").End(xlUp).Row
For i = 2 To iLastrow
If Application.And(rng(i, 1) = Location, rng(i, 2) = Age, rng(i, 3) =
Gender) Then
' Get Data
End If
Next i
End Sub
Sub Looktest()
' Replace parameters by controls e.g Call TestLookup(ListboxA.value,
ListboxB.value,listboxC.Value)
Call TestLookup("London", 24, "Female")
End Sub
HTH
"Michael" wrote:
Ex. Pull a group of people 24 years of age, from London, that are female.
where Control A = City(London), control B = Age(24), Control C =
Gender(Female)
|