Home > Mobile >  How to get google sheet column values by active range selection?
How to get google sheet column values by active range selection?

Time:11-02

Below  is the sample function which I tried. How do I achieve this loop through current active selection in google sheet and its values in an array.

function awe(){
  var selected1 = sheetname.getActiveRange()
var values = selected1.getValue()
}

I am getting only value i.e in first cell in google sheet instead of the range which I selected. I want the values of all current active selected range in an array.

I want only the user selected range values only to array in google app script to process.

CodePudding user response:

You can try Replacing: .getValue(); With: .getValues();

CodePudding user response:

Displaying Selected Data

function awe() {
  const vs = SpreadsheetApp.getActiveRange().getValues();
  SpreadsheetApp.getUi().showModelessDialog(HtmlService.createHtmlOutput(`<textarea cols="50" rows="15">${JSON.stringify(vs)}</textarea>`), "Selected Data");
}

Selected Data Sample:

A B C D E F G H I J
1 COL1 COL2 COL3 COL4 COL5 COL6 COL7 COL8 COL9 COL10
2 3 16 19 5 18 11 13 15 8 7
3 3 0 6 11 11 1 0 11 17 6
4 14 3 3 10 12 17 5 14 7 6
5 8 19 6 8 3 3 19 13 4 18

Dialog:

enter image description here

  • Related