Beka Zakaidze
Beka Zakaidze

Reputation: 21

Google Sheets Add Column cells notes from Corresponding cells from other column

I have 2 columns. Want to add Column 2 values as notes for Column 1 cells.

For example:

Col 1 Values:

test 1
test 2
test 3
test 4

Col 2 Values:

note value 1
note value 2
note value 3
note value 4

Want this result:

Col 1 Values:

test 1 - note (note value 1)
etc...

Upvotes: 1

Views: 80

Answers (1)

Marios
Marios

Reputation: 27350

Explanation:

You can get the notes from rng2 and set them in rng1 by using setNotes.

Note that:

  • rng1 and rng2 needs to be of the same dimension, in this case length.

Feel free to change the ranges (rng1 & rng2) but respect the above condition.

Solution:

function myFunction(){
   const ss = SpreadsheetApp.getActive();
   const sh = ss.getSheetByName("Sheet1"); // change that to your sheet name
   const rng1 = "A2:A" ; // range you want to add notes
   const rng2 = "B2:B"; // range you want to get notes
   const notes = sh.getRange(rng2).getValues();
   sh.getRange(rng1).setNotes(notes);
}

Upvotes: 1

Related Questions