I need a script for google sheets. My worksheet has 2 sheets called SOURCE and TARGET.
The TARGET sheet has the following columns and ranges: BO_BENE_ID range A2 – A2392, BENE_BIRTH_DT range E2 – E2392, BENE_FIRST_NAME range F2 – F2392, BENE_LAST_NAME range G2 – G2392.
The SOURCE sheet has the following columns and ranges: BO_BENE_ID range A2 – A106761, BENE_BIRTH_DT range J2 – J106761, BENE_FIRST_NAME range L2 – L106761, BENE_LAST_NAME range N2 – N106761.
When a BO_BENE_ID from TARGET range A2 – A2392 is equal to a cell from SOURCE range A2 – A106761 the script should copy the BENE_BIRTH_DT, BENE_FIRST_NAME, and BENE_LAST_NAME that from that row in SOURCE sheet and copy it to BENE_BIRTH_DT, BENE_FIRST_NAME, and BENE_LAST_NAME in the row with the matching BO_BENE_ID in the TARGET sheet.
I am very new at this and have been trying to stitch something together from other posts but I can’t get it to work. Any guidance would be hugely appreciated. Thank you
I have tried looking at other scripts that search for a value and replace a cell but I have been unable to get the desired outcome. I have tried getting an AI developed script based on my desired outcome but that was nowhere near what I needed to do.
2
Answers
Try this:
Source Sheet:
Target Sheet:
Before:
After:
Although I’m not sure whether I could correctly understand your question, how about the following sample script?
In this sample script, from your question, it has already known the target columns of "SOURCE" and "TARGET" sheets. So, I used this situation.
Sample script:
Please copy and paste the following script to the script editor of Spreadsheet. And, please confirm the sheet names and target columns of each sheet in
obj
.Testing:
When this script is run, the following sample situation is obtained.
Note:
In this sample script, it supposes the following situation.
BO_BENE_ID
are unique values in "SOURCE" sheet. There are no duplicate values.References: