For each value (in another sheet) that matches my lookup value, insert a separate row and link with lookup data

Dopper

New Member
Joined
Apr 5, 2016
Messages
1
In Sheet1 I have case-specific data (A is sitenumber, B is sitetypes that are present in the specific sitenumber):

A - B - C

1 - 1H31 - ...

1 - 1H71 - ...

1 - 1H93 - ...

2 - 2H34 - ...

Sheet2 contains general data about all sites, including the species that live there. Multiple species can occur per sitetype (C).

A - B - C

1 - 1H31 - Dog

1 - 1H31 - Cat

1 - 1H31 - Fly

1 - 1H34 - Rat

1 - 1H71 - Spider

....

57 - 57H23 - Dog

I want to do the following: If the sitetype in Sheet1,columnB matches the sitetype in Sheet2,columnB, the species from Sheet2,columnC should be added to Sheet1,columnC. HOWEVER, most of the time multiple matches can be found for the sitetypes in columns B. In those cases, I want to insert all these species in Sheet1 by inserting rows below the row where the first match was found.

So you would end up with this in Sheet1:

A - B - C

1 - 1H31 - Dog

1 - 1H31 - Cat

1 - 1H31 - Fly

1 - 1H71 - Spider

1 - 1H93 - Dog

1 - 1H93 - Butterfly

...

Anybody that can help me find either a formula of VBA-code for this? It has to link 2 sheets by looking up multiple values in Sheet2, inserting dito rows accordingly in Sheet 1 and then pasting multiple lookup / index-match values in these rows in Sheet1. ALSO, if NO species is listed in Sheet 2,column C, NO row should be inserted.

Hope its clear and thank you very much!
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.

Forum statistics

Threads
1,215,417
Messages
6,124,789
Members
449,188
Latest member
Hoffk036

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