searching an cellvalue in listobject depending on 2 search criteria

Renan

New Member
Joined
Aug 21, 2018
Messages
1
Hello together,

i am new here and i hope that someone with deeper Excel VBA knowledge can help me out with my problem.

I got an Listobject (see my example below) where i have some data. To be specific it has the columns year, week and value.

I need to write a function in VBA which has the input parameters year and week and the output parameter value.
It should search my Listobject like this:
1) search column YEAR for the given year (there are multiple entires up to 53, 1 Year can have 52 to 54 Weeks)
2) search in the columns that have this year listed for the week.
3) put the specific data from the column VALUE that belongs to the searched year and week. There can only be 1 match for this.

How can i realise that?


Example:

Function input: 2018, 4
Funktion output: D

[TABLE="width: 200"]
<tbody>[TR]
[TD]YEAR[/TD]
[TD]WEEK[/TD]
[TD]VALUE[/TD]
[/TR]
[TR]
[TD]2018
[/TD]
[TD]1[/TD]
[TD]A[/TD]
[/TR]
[TR]
[TD]2018[/TD]
[TD]2[/TD]
[TD]B[/TD]
[/TR]
[TR]
[TD]2018[/TD]
[TD]3[/TD]
[TD]C[/TD]
[/TR]
[TR]
[TD]2018[/TD]
[TD]4[/TD]
[TD]D[/TD]
[/TR]
[TR]
[TD]2019[/TD]
[TD]1[/TD]
[TD]E[/TD]
[/TR]
[TR]
[TD]2019[/TD]
[TD]2[/TD]
[TD]F[/TD]
[/TR]
[TR]
[TD]2019[/TD]
[TD]3[/TD]
[TD]G[/TD]
[/TR]
[TR]
[TD]2019[/TD]
[TD]4[/TD]
[TD]H[/TD]
[/TR]
[TR]
[TD]2019[/TD]
[TD]5[/TD]
[TD]I[/TD]
[/TR]
</tbody>[/TABLE]

Thank you very much!
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest

Forum statistics

Threads
1,224,814
Messages
6,181,125
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top