Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Excel relationship/replace ?

Posted on 2016-09-03
5
Medium Priority
?
47 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 33

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 33

Accepted Solution

by:
Subodh Tiwari (Neeraj) earned 2000 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 33

Expert Comment

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

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
Microsoft's Excel has many features that most people will never need nor take advantage of.  Conditional formatting is one feature that you may find a necessity once you start using it.
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…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…

916 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