Solved

Excel relationship/replace ?

Posted on 2016-09-03
5
34 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

911 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

21 Experts available now in Live!

Get 1:1 Help Now