0
votes

Beginner vba user.

I'm trying to create a function that will allocate the correct client_id in cell C2:C6, using the House and the Date values.

enter image description here

One House could have had multiple client_ids over time, so I need to allocate the correct client_id based on the Joining Date.

The function needs to find all instances where the House value is the same in the range A9:C13.

Below is the desired outcome:

enter image description here

The first step is setting the range, and then looping through this range for column B to find all instances where the house number matched the value in this column.

If I set the known range:

Dim rng As Range: Set rng = Application.Range("Data!A10:C13")

How do I loop over this range for column B?

1
this can be done with a formula.user4039065
I don't understand why you put in C1 0055G11. The date has no Joining Date match.Black.Jack

1 Answers

0
votes

After editing to properly reference a parent worksheet, run:

range("c2:c6").formula = "=INDEX(A$10:A$13, AGGREGATE(14, 6, ROW($1:$4)/((C$10:C$13<A2)*(B$10:B$13=B2)), 1))"

This formula does depend on ascending join dates (per each house) in C10:C13.

enter image description here