473,419 Members | 1,593 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,419 software developers and data experts.

Merging two excel files, joined by ID

Hi,

I've got two excel files, one has a list of products and their current prices and they all have a product ID, I have another file with a list of price's that need updating. I was wondering what the best way of going about merging the two files together, with the old price and the new price using the ID's. The second file has a list of all the products on their system, the first has just a few of these which are on the other system. If anyone has any ideas of how to either write a macro or use scenario>merge? The problem i was having with the merge is that you can only have 32 cells at a go.

Cheers for any help.

Adam
Jul 3 '07 #1
1 2359
kadghar
1,295 Expert 1GB
Hi,

I've got two excel files, one has a list of products and their current prices and they all have a product ID, I have another file with a list of price's that need updating. I was wondering what the best way of going about merging the two files together, with the old price and the new price using the ID's. The second file has a list of all the products on their system, the first has just a few of these which are on the other system. If anyone has any ideas of how to either write a macro or use scenario>merge? The problem i was having with the merge is that you can only have 32 cells at a go.

Cheers for any help.

Adam
using a excel, the easiest way is with FindV, that shouldnt take more than 1 minute. (dont forget to put 0 in the las parameter, that fixes 90% of the data mistakes) (yeah, i've just come with that 90% so what?)

if you want to make it via code you can use with an sql, and just sort them by id

if you dont have any sql, use arrays and IF's this is a very bad and unefficient method but it works...

Expand|Select|Wrap|Line Numbers
  1. sub DontUseThis()
  2. dim OldID() as double
  3. dim NewID() as double
  4. dim i as long
  5. dim j as long
  6.  
  7. OldItems = 100 'You can do this with an eof
  8. NewItems = 100 'And this 2, but i dont know you DB
  9.  
  10. redim oldid(1 to olditems)
  11. redim newid(1 to newitems)
  12.  
  13. 'lets say you have in column A and B the ID and old price
  14. 'and you have E and F with ID and new prices
  15.  
  16. for i = 1 to olditems
  17. oldid(i)= cells(i,1).value
  18. next
  19. for i = 1 to newitems
  20. newid(i)= cells(i,5).value
  21. next
  22.  
  23. 'lets write the new prices in column C
  24.  
  25. for i = 1 to olditems
  26. j=1
  27. do
  28.  if oldid(i) = newid(j)  then
  29.    cells(i,3).value = cells(j,6).value
  30.    exit do
  31.  else
  32.    j=j+1
  33.  end if
  34. loop
  35. next
  36. next
  37. end sub
well hope that helps. Sometimes is faster to put the prices into arrays, create a result array and then write it down to excel..

Good Luck
Jul 3 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Andrew | last post by:
With command-line interface ( 3.23.37, UNIX Socket ) all is well with column aliasing. However, column aliases disappear in Excel, over ODBC, when there are multiple (joined) tables in the query. ...
4
by: rottyguy70 | last post by:
hello, am trying to do the following with little success. any help is appreciated. 1) assume i have a static mapping: a -> 1 b -> 2 c -> 3 2) i need to read through some data, let's say...
0
by: steve | last post by:
Hi there, I am trying to import data from 2 dbf files into excel using the 'get external data' option which launches ms query. Ultimately I am merging data with a right join statement. I can...
3
by: Damian Arntzen | last post by:
I'm a beginner to moderate programmer who's fiddling around with automating Excel, in particular after being able to have the user fill out a form and it then generate the workbook. I can't quite...
1
by: kevcar40 | last post by:
Hi I am importing two excel spreadsheets into access table 1 and table 2, the two spreadsheets have the same fields, i would like to join or merge these tables giving table 3 so a user can...
20
by: Marin Brkic | last post by:
Hello all, please, let me apologize in advance. English is not my first language (not even my second one), so excuse any errors with which I'm about to embarass myself in front of the general...
5
by: Albert-jan Roskam | last post by:
Hi, I wrote the program below to merge all xls files in a given directory into one multisheet xls file. It uses xlwt and xlrd. The xls files I use for input are generated by Spss. When I open and...
0
by: Albert-jan Roskam | last post by:
Hi John, Thanks! Using a higher xlrd version did the trick! Regarding your other remarks: -yep, input files with multiple sheets don't work yet. I kinda repressed that ;-) Spss outputs only...
1
by: BBMcL | last post by:
Advanced thanks for any helping. I'm running Python on a Mac OS X. Here's the basic situation. A single group of people had various health measurements performed on them over the course of a few...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.