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

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
which version of excel are you using?
also, do you have a sample to share?
 
Upvote 0
Hi ExceLoki

I am using Office 365

Here is a picture.

Thanks
 

Attachments

  • personParent.PNG
    personParent.PNG
    13.4 KB · Views: 14
Upvote 0
I am using Office 365

I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)
 
Upvote 0
I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)

Thanks Fluff. All done!

Hopefully someone somewhere comes up with a suggestion.

S
 
Upvote 0
might not be the prettiest solution possible, but it works. imagine someone else can clean it up or improve on it
----------------------
Book1
ABCDE
1person numberparent numberlevel 1 populationlevel numberFormula
212312412422
315911211222
416511111122
512498711
611298711
711198711
823512333
923615933
1023716533
11546787not knownnot found
12545787not knownnot found
13544789not knownnot found
1445823544
1545723644
1645623744
Sheet1
Cell Formulas
RangeFormula
E2:E16E2=IFNA(IF(MATCH(A2,$C$2:$C$16,0),1),IFNA(IF(MATCH(B2,$C$2:$C$16,0),2),IFNA(IF(MATCH(A2,$B$2:$B$16,0),3),IFNA(IF(MATCH(B2,$A$2:$A$16,0),4),"not found"))))
 
Upvote 0
Thanks do you know if i can extend the IFNA's so that the level number can reach 8?
 
Upvote 0
should be able to. i saw you wanted 1-8 and not found in the post, but i wasnt sure what other comparisons you were looking at.
 
Upvote 0
Thats me rushing to create some dummy data! the list looks at 5000+ records and will throw back levels 1 to 8. Let me give this a try tomorrow and ill let you know.

Thanks

S
 
Upvote 0
Hey ExcelLoki

I tried extending the formula to fit with my real dataset (Up to 9 levels and 5965 records in Column A and B) to:
=IFNA(IF(MATCH(A2,$C$2:$C$21,0),1),IFNA(IF(MATCH(B2,$C$2:$C$21,0),2),IFNA(IF(MATCH(A2,$B$2:$B$5965,0),3),IFNA(IF(MATCH(B2,$A$2:$A$5965,0),4),IFNA(IF(MATCH(B2,$A$2:$A$5965,0),5),IFNA(IF(MATCH(A2,$B$2:$B$5965,0),6),IFNA(IF(MATCH(B2,$A$2:$A$5965,0),7),IFNA(IF(MATCH(A2,$B$2:$B$5965,0),8),IFNA(IF(MATCH(A2,$B$2:$B$5965,0),9),"not found")))))))))

However its only returning results up to Level 4, do you know what i need to change to get it showing 9 level numbers?

Thanks

S

might not be the prettiest solution possible, but it works. imagine someone else can clean it up or improve on it
----------------------
Book1
ABCDE
1person numberparent numberlevel 1 populationlevel numberFormula
212312412422
315911211222
416511111122
512498711
611298711
711198711
823512333
923615933
1023716533
11546787not knownnot found
12545787not knownnot found
13544789not knownnot found
1445823544
1545723644
1645623744
Sheet1
Cell Formulas
RangeFormula
E2:E16E2=IFNA(IF(MATCH(A2,$C$2:$C$16,0),1),IFNA(IF(MATCH(B2,$C$2:$C$16,0),2),IFNA(IF(MATCH(A2,$B$2:$B$16,0),3),IFNA(IF(MATCH(B2,$A$2:$A$16,0),4),"not found"))))
 
Upvote 0

Forum statistics

Threads
1,214,644
Messages
6,120,709
Members
448,983
Latest member
Joaquim_Baptista

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