javascript - Google Script next cell in column - Stack Overflow

Been scouring the internet but not found a solutionBasically I am wanting to paste data in the next ava

Been scouring the internet but not found a solution

Basically I am wanting to paste data in the next available row in a specific column.

The column i want to paste into is H

Example - Cell H1 and H2 has data inside it - so i need the code to paste the values in H3 (next available cell)

Thanks

Been scouring the internet but not found a solution

Basically I am wanting to paste data in the next available row in a specific column.

The column i want to paste into is H

Example - Cell H1 and H2 has data inside it - so i need the code to paste the values in H3 (next available cell)

Thanks

Share Improve this question asked Jul 27, 2017 at 14:44 RedexRedex 911 gold badge2 silver badges13 bronze badges 1
  • 1 stackoverflow./questions/73777592/… is probably the shortest way – PhistucK Commented Apr 16, 2023 at 12:45
Add a ment  | 

2 Answers 2

Reset to default 3

got it working in the end.. For those of you interested my code is below

function putInNextAvaibleRow() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sht = ss.getSheetByName('Test');     //Rename to your sheet
  var row=1;                               //start row to loop through
  var col=8;                               //column you want to loop through
  var value=34567;                         //value you want to assign - can be a cell or anything
  while(sht.getRange(row,col).getValue()!=""){
    row++;
  }

  sht.getRange(row,col).setValue(value);
  Browser.msgBox("Sheet is "+row+".");
}

You can't access user's clipboard, Google drive API don't give this possiblity. But, you can put data in the next available row in a specific column. Here's the solution :

function putInNextAvaibleRow(sheet,col,value) {
  var row=1;
  while(sheet.getRange(row,col).getValue()!=""){
    row++;
  }
  sheet.getRange(row,col).setValue(value);
}

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744739852a4590963.html

相关推荐

  • javascript - Google Script next cell in column - Stack Overflow

    Been scouring the internet but not found a solutionBasically I am wanting to paste data in the next ava

    19小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信