2013-02-13 47 views
1

我已經開始創建一個電子表格來監視facebook,youtube等的一些結果......我做的很多事情我都能從之前的學習中學習到在這個網站上的答案。谷歌腳本複製列的值,並在電子表格中插入一個新的列

現在我堅持試圖找到一個腳本,它可以幫助我做到以下幾點:

A列中包含的指標
B列的描述包含提取從extrenal源的度量公式(例如我facbeook頁面的喜歡,數我的YouTube頻道的視頻瀏覽量)號

我想有它在每個星期一運行並執行以下操作的腳本:

  1. 插入新B列和C列之間的列(將B之後的所有列移動1個位置)
  2. 複製B列並僅粘貼新空列中的值(不包括公式)C
  3. 寫下類似周的內容開始YYYY/MM/DD在C列(C1)的頂部,其中YYYY/MM/DD是前一週的週一

我已經試過這個修改後的版本(從http://www.kraukoblog.com/marketing/tutorial-watch-your-competitors-facebook-pages-with-google-docs/)日期:

function UpdateFblikes() { 
    var sheet =SpreadsheetApp.getActiveSheet(); //define spreadsheet name 
    var column = sheet.getRange("O1").getValue(); 
    var row = 4; 
    Utilities.sleep(4000); // Slowdown the script (4 second) 
    var nblike = sheet.getRange("E4:E60"); // Select and copy the column 
    nblike.copyValuesToRange(sheet, column+5, column+5, row, row+56); // Paste the data 
    sheet.getRange(3, column+5).setValue(new Date()); // add date in column title 
    sheet.getRange("O1").setValue(column+1); // Incremente variable 
} 

但它只在列中寫入日期。

這將使我能夠比較這些指標的每週更改。

這可能嗎?

回答

1

我已經能夠通過瀏覽谷歌開發者頁面上的不同教程來找到解決方案。這是我創建的功能

function insertcolumn() { 
// The code below will insert 1 column after column 5 in sheet 4 
var ss = SpreadsheetApp.getActiveSpreadsheet(); 
var sheet = ss.getSheets()[4]; 
sheet.insertColumns(5, 1); 


// Get the range of cells that store data to be copied having created a named range for the column in the spreadsheet. 
    var valuestocopy = ss.getRangeByName("valuestocopy") 


// The code below copies the range valuestocopy cells to column five up to 100 rows 

valuestocopy.copyValuesToRange(sheet, 5, 5, 1, 100); } 
+1

你把這個功能放在哪裏?我試圖做類似但自定義函數不允許寫入單元格。 – Hippyjim 2013-11-09 16:41:48

相關問題