VBA Code for Replacing Row values by matching unique code

gfdwer2

New Member
Joined
Jan 22, 2020
Messages
24
Office Version
  1. 2016
  2. 2010
Platform
  1. MacOS
Hi guys, need help finding VBA code for this. Please see pictures attached.

For example (Picture 1)

IF I input 5 in (Sheet 1, Range C4), THEN the values in Sheet 1 under Row 8 should replace the values in Sheet 2 at the right side of special code 5, since the special or unique codes matched.

Then instead of 5, the special code in Sheet 2 will become 5E (not necessary, this is only to identify that it has been edited or changed).
1E9F7D93-BBE8-40BD-A06C-94284F1F8E30.jpeg



Picture 2 is the expected result:
Note that the data in sheet 2 can go up to maximum of 5000 Rows.

58B0447D-0C55-43C4-B524-DF9CF53F6CFE.jpeg


I hope someone can help.
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Try this

VBA Code:
Sub Replace_Data()
  Dim f As Range
  Set f = Sheets("Sheet2").Range("A:A").Find(Sheets("Sheet1").Range("C4").Value, , xlValues, xlWhole)
  If Not f Is Nothing Then f.Offset(, 1).Resize(1, 7).Value = Sheets("Sheet1").Range("A8:G8").Value
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,815
Messages
6,181,135
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top