Finding values within a row, replacing with other values if match

Subspace

New Member
Joined
Nov 10, 2022
Messages
4
Office Version
  1. 365
Platform
  1. Windows
Hi,

I'm very new to this, so my apologies. I've tried searching for the answer with no luck, although I'm sure this has been answered many times, I just don't know the correct search parameters.

Basically, I want to search a row, if data matches in another workbook, then replace with data from the other workbook. I can't work out how to search a row of data. See attached image.
Something like, IF A1+B1+C1+D1+F1= Same data from another workbook THEN replace column 'E1' with predetermined information (Or replace entire row is fine too, although I would prefer if B1 wasn't affected).

I have a large source workbook to work from and doing this manually is time consuming. I also have to do it daily.

The data always has the same information in each column, but the rows could be different. Is there a way for VBA to search each row of my new workbook and replace it with data from my source workbook if it matches one of the rows in my source workbook?

I'd attempt to write what I want, but I'll fumble it.
So instead, I found this, which I think is right, but I want it to search more of the row before replacing the "E column" in the row.

Any thoughts would be appreciated.
 

Attachments

  • replacing values.JPG
    replacing values.JPG
    22 KB · Views: 15

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
1. About how many rows of data on each workbook?


2. What predetermined information?

3. Can you give an example of data on both workbooks?
Hi Akuini,

Thank you for your response.

1. The amount of rows varies between 50 and 200 daily, but the columns are always 12 and have the same information in them day by day.

2. The information being pulled from one work book to another.
I want to read a row from workbook 1, find it in workbook 2 and if enough columns in the row match, replace row in workbook 1.
Rinse repeat for all rows

3. The data is numbers, names and more numbers
The data is the same each day, like it might say:
| 3 | James | 25125 | For exchange (or some other wording)
But I want them reformatted to say:
| 3 | Louis | 25125 | For exchange |

In the OP I attached an image of a "before" and "After" assume instead they were in two separate workbooks - I suppose as I say this, I could post the information into another sheet in workbook 1 if it's impossible to pull data between workbooks
The image in the OP is:
Before: Rows 1,2 & 3
to be replaced with
After: Rows 6, 7 & 8

This could be the ramblings of a madman, but I hope this makes sense to someone.

Thank you again Akuini

-Subspace
 
Upvote 0
It's a bit difficult for me to understand your explanation.
Could you upload samples of both workbook (without sensitive data) to a sharing site like dropbox.com or google drive?
 
Upvote 0
It's a bit difficult for me to understand your explanation.
Could you upload samples of both workbook (without sensitive data) to a sharing site like dropbox.com or google drive?
Hi Akuini,

I've uploaded documents called TEST1 and TEST2. I want a script that reads each column in TEST1, compares it to TEST2, then replaces TEST1 with TEST2's data.
The main information is that the "parts" and "code" columns line up.

I could copy the TEST2 data into another worksheet within TEST1's workbook if it's not possible otherwise, but I'd have to do it daily. TEST1 can be active and TEST2 always has the same name.



Thank you again for your time.
 
Upvote 0
Hi Akuini,

I've uploaded documents called TEST1 and TEST2. I want a script that reads each column in TEST1, compares it to TEST2, then replaces TEST1 with TEST2's data.
The main information is that the "parts" and "code" columns line up.

I could copy the TEST2 data into another worksheet within TEST1's workbook if it's not possible otherwise, but I'd have to do it daily. TEST1 can be active and TEST2 always has the same name.



Thank you again for your time.
* I mean each ROW: " I want a script that reads each row in TEST1"
 
Upvote 0

Forum statistics

Threads
1,215,066
Messages
6,122,948
Members
449,095
Latest member
nmaske

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