Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Compare two arrays

Posted on 2006-07-06
Last Modified: 2010-04-30
I have two arrays filled with inventory part numbers and pricing information.

Dim existing400(2000, 4)  ~600 items
Dim New400(2000, 3)      ~1200 items

existing400(1,1) 'part number
existing400(1,2) 'Item description
existing400(1,3) 'unit price
existing400(1,4) 'unit price from "New400" array

new400(1,1) 'part number
new400(1,2) 'Item description
new400(1,3) 'unit price

What I am looking to accomplish is to fill the first array(existing400(1,4)) with the current pricing from the second array(new400).  

I need ideas on how to set this up.

Question by:RobertStamm
  • 2
  • 2
LVL 13

Accepted Solution

rettiseert earned 250 total points
ID: 17051040
Try this:

    Dim I As Long, J As Long
    For I = LBound(existing400) To UBound(existing400)
        For J = LBound(New400) To UBound(New400)
            If existing400(I, 1) = New400(J, 1) Then
                existing400(1, 4) = New400(1, 3)
            End If

Author Comment

ID: 17051292
Found a opps but I was able to fix it.  

existing400(1, 4) = New400(1, 3)
Should have been.
existing400(I, 4) = New400(J, 3)

Works great.
Thank you.
LVL 13

Expert Comment

ID: 17051485
yes, a little mistake : )

also, you would like to add a
exit for
after the existing400(I, 4) = New400(J, 3) line

Author Comment

ID: 17051548

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Copy a row 12 62
Access Object Property from VBA Module in Excel 2010 2 36
Create Files based on Cell Values in a Range in Excel 12 43
pop out of webbrowser1 control vba6 5 24
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

766 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question