最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Google Script next cell in column - Stack Overflow

programmeradmin1浏览0评论

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);
}
发布评论

评论列表(0)

  1. 暂无评论