Loop thru a sheet, find identical text in different file, insert new row

Brutusar

Board Regular
Joined
Nov 23, 2019
Messages
166
Office Version
  1. 365
Platform
  1. Windows
I am trying to make an outline for a sub that should be relatively simple, but I am stuck anyway.

In the sheet "Airports", there are two columns containing 5 letter airport codes. (Always 5 letters). "From Airport" is in col A, "To Airport" is in col b.

In the sheet "Conditions" there are 6 columns, the first two are airports, the remaining are general text. The number of rows will vary from time to time.Each cell in the two first columns may be either a airport code matching the airport codes in the first sheet, or it can be "ALL". ALL mean that the text in the same row should be written in for all airports, either both FROM and TO, or FROM a airport to ALL, or FROM ALL to a airport.

The sheet "Result" shows how the result should be.

I guess the way to do this is to loop thru the rows in the "Conditions", and then compare the airport codes with those in the sheet Airport codes", and if identical cells in a row is found a new row should be inserted, and the text pasted in.

The main question is how to handle situations when one (Either From or To is "ALL")

Anyone have a good idea on that?

ExampleWB.xlsx
G
24
Condititions
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Cross-posting (posting the same question in more than one forum) is not against our rules, but the method of doing so is covered by #13 of the Forum Rules.

Be sure to follow & read the link at the end of the rule too!

Cross posted at: Loop thru a sheet, find identical text in different file, insert new row
If you have posted the question at more places, please provide links to those as well.

If you do cross-post in the future and also provide links, then there shouldn’t be a problem.
 
Upvote 0

Forum statistics

Threads
1,212,929
Messages
6,110,741
Members
448,295
Latest member
Uzair Tahir Khan

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