Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to access the cell next to the selected cell in Google sheet using script?

I just started exploring google sheets and javascript and I wrote a function which prompts the user to type a string which is entered into the selected cell. I’m accessing the current cell using SpreadsheetApp.getActiveSheet().getActiveCell() and setting the value using .setValue().

Now I made another prompt and I want to put this value in the cell next to the selected cell (same row but column+1). How do I access the current cells row and column positions and then increment the col with 1?

In pseudo code im thinking something like this;
ActiveCell[row][column+1] = string input from prompt2

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Try using offset to specify offset:

let cell = SpreadsheetApp.getActiveSheet().getActiveCell();

// update cell to the right
cell.offset(0, 1).setValue("upd");
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading