Excel - Formula/VBA help

ShilP

New Member
Joined
Oct 8, 2015
Messages
30
Office Version
  1. 365
Platform
  1. Windows
Hi Guys

I hope you are all well. Im looking for some help to either work out a formula or some vba:

Sheet 1
Column A (Can contain an ID List)
Column B (Can contain an ID LIst)
Column C (Can Contain an ID List)
Column D (Will be used for workings)

1. In Column D - i want to look at Column A and if found in column C enter a value of 1 (as a base level to start with). Returning the rest as BLANK

Then in remainder cells of Column D, i want to look at Column B and if found in Column C enter value as 2. returning rest as blank

Then i would like to loop this somehow so that the remaining cells in Column D, look to see if Column B has a match with those with Column D and Value - 2, and if match found return in Column D Value as "3"

Then i would like to repeat this until we are left with a set of ID's not found when matched to Column B and will enter a value of Column D as "Not found".

In the End Column D will have a number 1-8, or "Not Found".

I currently do this manually using v lookups at the moment using multiple columns but was wondering if there was a quicker way as i repeat this each month.

Appreciate your help as always.

S
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Hi All

Does anyone have any solutions for the above? just seeing if i can improve this problem im having with the formula.

=IFERROR(1/(1/(COUNTIF($C$2:$C$4,A2)+(COUNTIF($C$2:$C$4,B2)>0)*2+IFERROR(VLOOKUP(B2,$A$1:$D1,4,0)+1,0))),"Not Known")

Thanks

S
 
Upvote 0
Hi All

Does anyone else have any suggestions i could try here?

Thanks

S
 
Upvote 0
Could you upload a new mini sheet again via XL2BB, with newest formula and new id update ?
 
Upvote 0
Thanks Bebo

Here it is now the ID's are alphanumeric and not just numbers. The green column is the correct outcome. The column "Level Number is where i would to place a formula":

PersonParent.xlsx
ABCDEF
1Person NumberParent NumberLevel 1 PopulationLevel NumberLevel Number
2AA123AA124AA1242
3AA159AA112AA1122
4AA165AA111AA1112
5AA124AA9871
6AA112AA9871
7AA111AA9871
8AA235AA1233
9AA236AA1593
10AA237AA1653
11AA546AA787Not Known
12AA545AA787Not Known
13AA544AA789Not Known
14AA458AA2354
15AA457AA2364
16AA456AA2374
17AA595AA4585
18AA596AA4575
19AA597AA4565
20AA311AA5956
21AA312AA5966
22AA313AA5976
23AA211AA3117
24AA212AA3127
25AA213AA3137
26AA601AA2118
27AA602AA2128
28AA603AA2138
29AA782AA6019
30AA788AA6029
31AA781AA6039
Sheet1
 
Upvote 0
using @bebo021999 original solution works for me using the recently added mini sheet. but i did find an issue once you add more data to column c, where the values can go over 9 as shown below. is this the issue you're having?
Excel Formula:
=IFERROR(1/(1/(COUNTIF($C$2:$C$30,A2)+(COUNTIF($C$2:$C$30,B2)>0)*2+IFERROR(VLOOKUP(B2,$A$1:$D1,4,0)+1,0))),"Not Known")
-----------------------------
ifna-if-ifna-if matching in columns.xlsx
ABCD
1Person NumberParent NumberLevel 1 Populationbebo
2AA123AA124AA1242
3AA159AA112AA1122
4AA165AA111AA1112
5AA124AA9871
6AA112AA9871
7AA111AA9871
8AA235AA1233
9AA236AA1593
10AA237AA1653
11AA546AA787Not Known
12AA545AA787Not Known
13AA544AA789Not Known
14AA458AA2354
15AA457AA2364
16AA456AA2375
17AA595AA458aa4565
18AA596AA4575
19AA597AA4568
20AA311AA5956
21AA312AA5966
22AA313AA5979
23AA211AA3117
24AA212AA3127
25AA213AA31310
26AA601AA2118
27AA602AA2128
28AA603AA21311
29AA782AA6019
30AA788AA6029
31AA781AA60312
Sheet2
Cell Formulas
RangeFormula
D2:D31D2=IFERROR(1/(1/(COUNTIF($C$2:$C$30,A2)+(COUNTIF($C$2:$C$30,B2)>0)*2+IFERROR(VLOOKUP(B2,$A$1:$D1,4,0)+1,0))),"Not Known")
 
Upvote 0
using @bebo021999 original solution works for me using the recently added mini sheet. but i did find an issue once you add more data to column c, where the values can go over 9 as shown below. is this the issue you're having?
Excel Formula:
=IFERROR(1/(1/(COUNTIF($C$2:$C$30,A2)+(COUNTIF($C$2:$C$30,B2)>0)*2+IFERROR(VLOOKUP(B2,$A$1:$D1,4,0)+1,0))),"Not Known")
-----------------------------
ifna-if-ifna-if matching in columns.xlsx
ABCD
1Person NumberParent NumberLevel 1 Populationbebo
2AA123AA124AA1242
3AA159AA112AA1122
4AA165AA111AA1112
5AA124AA9871
6AA112AA9871
7AA111AA9871
8AA235AA1233
9AA236AA1593
10AA237AA1653
11AA546AA787Not Known
12AA545AA787Not Known
13AA544AA789Not Known
14AA458AA2354
15AA457AA2364
16AA456AA2375
17AA595AA458aa4565
18AA596AA4575
19AA597AA4568
20AA311AA5956
21AA312AA5966
22AA313AA5979
23AA211AA3117
24AA212AA3127
25AA213AA31310
26AA601AA2118
27AA602AA2128
28AA603AA21311
29AA782AA6019
30AA788AA6029
31AA781AA60312
Sheet2
Cell Formulas
RangeFormula
D2:D31D2=IFERROR(1/(1/(COUNTIF($C$2:$C$30,A2)+(COUNTIF($C$2:$C$30,B2)>0)*2+IFERROR(VLOOKUP(B2,$A$1:$D1,4,0)+1,0))),"Not Known")
Thanks Excel Loki.

Yes thats correct, the population in Column C can grow up to 40 different numbers. As total sheet can contain around 6000 total records. I feel like we are nearly there but struggling to get it working.

Does anyone have any ideas?
 
Upvote 0

Forum statistics

Threads
1,214,891
Messages
6,122,105
Members
449,066
Latest member
Andyg666

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