Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Comparing records from 2 tables

Hello Everyone.
I wasn't reading those newsgroups for a few years.
Time flies.

I hope someone can help me.

I have data extracted through ODBC to 2 sheets.
Sheet "01" contains all purchase order lines in the last two years. About
30,000 records.
Sheet "MD", (Multiple delivery), contains about 3,000 records.
All fields on 01 are in MD, but MD sheet has a few additional fields in the
middle.

I copy the whole sheet MD to 'Report' sheet, since I need all delivery
details, and have to add remaining records from 01 sheet, excluding already
existing purchase order lines on MD.
I used on 01 sheet Index / Match formula to mark in the column on the right
records that already exist on MD and then can use filter to copy and paste
remaining records but I would like Purchasing Supervisor to 'press a button'
and have this done automatically.

I have problem with two steps. One is with selecting the range
automatically, the other is Do Until loop. I have never created macro that
does looping at all.
I can see those two being really useful for us, since we have a lot of table
structured data imported through ODBC.

Could someone help, please.

Thank you in advance.
Wes



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Comparing records from 2 tables

Dim rng as Range, rng1 as Range, cell as Range
Dim res as Variant
set rng = worksheets("MD").Range("A1").CurrentRegion
set rng1 = worksheets("01").Range("A1").CurrentRegion.Columns (1).Cells
for each cell in rng.columns(1).Cells
if cell.row = 1 then
' do nothing, header row
else
' process the row
res = Application.match(cell.Value,rng1,0)
if not iserror(res) then
' match found for column A values
msgbox rng1(res).Address(external:=True
else
' not found
end if
end if
Next

assume the value in column A is sufficient for a match. If not, then you
would need to use the Find command, find matches in column A (or other more
appropriate column which will narrow the possible matches, then check all
the possible for the fields that determine a match).

--
Regards,
Tom Ogilvy


"Wes Zalewski" wrote in message
...
Hello Everyone.
I wasn't reading those newsgroups for a few years.
Time flies.

I hope someone can help me.

I have data extracted through ODBC to 2 sheets.
Sheet "01" contains all purchase order lines in the last two years. About
30,000 records.
Sheet "MD", (Multiple delivery), contains about 3,000 records.
All fields on 01 are in MD, but MD sheet has a few additional fields in

the
middle.

I copy the whole sheet MD to 'Report' sheet, since I need all delivery
details, and have to add remaining records from 01 sheet, excluding

already
existing purchase order lines on MD.
I used on 01 sheet Index / Match formula to mark in the column on the

right
records that already exist on MD and then can use filter to copy and paste
remaining records but I would like Purchasing Supervisor to 'press a

button'
and have this done automatically.

I have problem with two steps. One is with selecting the range
automatically, the other is Do Until loop. I have never created macro that
does looping at all.
I can see those two being really useful for us, since we have a lot of

table
structured data imported through ODBC.

Could someone help, please.

Thank you in advance.
Wes





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Comparing 2 tables Bobby Dreamer Excel Worksheet Functions 0 August 21st 08 06:11 AM
Comparing 2 lists to display only records in 1 but not in both lis Craig Excel Discussion (Misc queries) 1 August 2nd 08 11:36 PM
Matching Records in two tables Richard Buttrey Excel Worksheet Functions 2 February 21st 08 09:30 AM
Comparing 2 Tables Carl Excel Worksheet Functions 6 July 7th 06 02:36 AM
Comparing two tables Peter Steiner Excel Discussion (Misc queries) 6 December 23rd 05 10:11 AM


All times are GMT +1. The time now is 09:52 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"