Avatar of acdecal
acdecal
 asked on

Compare two worksheets and insert row

I have an excel 2010 workbook with a worksheet that pulls in data from an outside source (about 150 cost codes and descriptions).  On another worksheet in the same workbook I have data in the first two columns that was copied from the first sheet originally.  When a new query is run to update the first sheet, I would like to include code that would compare the two sheets row by row and update the second sheet by inserting rows if a new cost code is found.  

Please let me know if you need more information.
Thanks
Microsoft ExcelVisual Basic ClassicVB Script

Avatar of undefined
Last Comment
gowflow

8/22/2022 - Mon
gowflow

yes can you post a sample would be easier to apply code
gowflow
Robberbaron (robr)

A before and After sample is also helpful.
and record a macro that has the steps you would use to manually create the desired result as this gives a idea of what you are trying to achieve.,
acdecal

ASKER
OK, I attached a sample file and recorded a macro in module1.  The workbook is currently in a state that would result from running a new query where a row was added in the "Query Sheet" ws (row 12 in red).  The lists in columns A & B were previously identical to the lists in columns A & B in the "Related Data" ws.  I need code to run after the query to check for any changes in the "Query Sheet" and insert a corresponding row in the "Related Data" sheet.

Hope this helps clarify.
WB-Before.xlsm
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
gowflow

Let me recap
You would get the workbook in this status ? like it is now like you posted ? and what you want to acheive is go thru the data in Querry Sheet and if it finds a code that does not exit in Related Data to simply insert it wher eit should be correct ???
gowflow
acdecal

ASKER
Yes, but I need to insert a complete new row but only copy the code and description.
ASKER CERTIFIED SOLUTION
gowflow

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
acdecal

ASKER
OK great.  I think that will work.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
gowflow

Glad I could help.
gowflow