Solved

Excel relationship/replace ?

Posted on 2016-09-03
5
32 Views
Last Modified: 2016-09-03
Hello,

I have an issue in Excel I am hoping someone can help me with! In spreadsheet I, I have two columns of data, call them A and B (about 17,000 rows).  A and B are related in a way that they are two different identifiers for the same thing. In spreadsheet II, I have just a portion of the rows of Column A (about 9,000 rows). I need to replace the data in Spreadsheet II, Column A with the data from Spreadsheet I, Column B, ensuring that the relationship maintains. Does this make sense? Basically, I am switching which product ID codes I am using in an inventory spreadsheet but I have to make sure I replace the existing codes with the exact new ones. Thanks a million!
0
Comment
Question by:Michael Freedman
  • 3
  • 2
5 Comments
 
LVL 28

Expert Comment

by:Subodh Tiwari (Neeraj)
ID: 41783030
Can you upload small sample workbooks along with the desired output mocked up manually?
That will help us to know exactly what you are trying to achieve.
0
 

Author Comment

by:Michael Freedman
ID: 41783042
Yes, please see attached. Sheet 1 and Sheet 2. Items in yellow on Sheet 2 are complete. This process is very easy with only 20 rows, but I have 17,000. Thanks!
Example.xlsx
0
 
LVL 28

Accepted Solution

by:
Subodh Tiwari (Neeraj) earned 500 total points
ID: 41783055
Please try this....
Sub ReplaceValues()
Dim sws As Worksheet, dws As Worksheet
Dim x, y, dict
Dim i As Long
Set sws = Sheets("Sheet1")
Set dws = Sheets("Sheet2")
x = sws.Range("A1").CurrentRegion.Value
y = dws.Range("A1").CurrentRegion.Value
Set dict = CreateObject("Scripting.Dictionary")
For i = 1 To UBound(x, 1)
   dict.Item(x(i, 1)) = x(i, 2)
Next i

For i = 1 To UBound(y, 1)
   y(i, 1) = dict.Item(y(i, 1))
Next i
dws.Range("A1").Resize(UBound(y, 1)).Value = y
Set dict = Nothing
End Sub

Open in new window

0
 

Author Comment

by:Michael Freedman
ID: 41783062
Great! Thank you! I have no idea what it means but a friend says he understands. haha
0
 
LVL 28

Expert Comment

by:Subodh Tiwari (Neeraj)
ID: 41783064
You're welcome Michael! Glad to help.
Thanks for the feedback. :)
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Introduction While answering a recent question (http:/Q_27311462.html), I created an alternative function to the Excel Concatenate() function that you might find useful.  I tested several solutions and share the results in this article as well as t…
Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

708 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now