Posts

Showing posts with the label google-apps-script

Google Sheets Auto Date and Time Stamp on Multiple Columns

Image
Clash Royale CLAN TAG #URR8PPP Google Sheets Auto Date and Time Stamp on Multiple Columns I want my Google Sheet to automatically do the following: I have already added named ranges for Columns A through E as follows: I found a code that lets me do the datestamp/timestamp thing, but it only works for one column (from https://www.internetgeeks.org/tech/add-timestamp-time-stamp-google-docs-spreadsheet/): function onEdit(event) { var timezone = "PST"; var timestamp_format = "MM-dd-yy"; var updateColName = "Title"; var timeStampColName = "Date"; var sheet = event.source.getSheetByName('Sheet1'); var actRng = event.source.getActiveRange(); var editColumn = actRng.getColumn(); var index = actRng.getRowIndex(); var headers = sheet.getRange(1, 1, 1, sheet.getLastColumn()).getValues(); var dateCol = headers[0].indexOf(timeStampColName); var updateCol = headers[0].indexOf(updateColName); updateCol = updateCol + 1; if (date...

How to automatically import data from uploaded CSV or XLS file into Google Sheets

Image
Clash Royale CLAN TAG #URR8PPP How to automatically import data from uploaded CSV or XLS file into Google Sheets I have a legacy database system (not web accessible) on a server which generates CSV or XLS reports to a Google Drive folder. Currently, I am manually opening those files in Drive web interface and converting them to Google Sheets. I would rather this be automatic so that I can create jobs that append/transform and graph the data in other sheets. Is it possible to output a native .gsheet file? Or is there a way to convert CSV or XLS to .gsheet programmatically after saving it to Google Drive either in Google Apps or via a Windows based script/utility? google-spreadsheet-api can import data into an existing google spreadsheet. I suspect Drive API has a way to import as a new spreadsheet file, as I think I saw some code for the import on SO. – eddyparkinson Nov 11 '14 at 4:33 ...

increment a cell in google sheets each day

Image
Clash Royale CLAN TAG #URR8PPP increment a cell in google sheets each day I have a script that needs to increment a cell every day. I have tried several methods comparing dates with the current date with the previous recorded date but that doesn't seem to work at all. I am recording the day each time there is an entry, which I was using to increment the cell, with the following var curDate = Utilities.formatDate(new Date(), "GMT-5", "MM/dd/yyyy") the last thing I did to compare them was the following: var today = parseInt(Utilities.formatDate(new Date(),"EST","D")); var lastRecordedDay = parseInt(Utilities.formatDate(new Date(SpreadsheetApp.getActiveSpreadsheet().getSheetByName("total").getRange(challegeDay,3).getValues()),"EST","D")); if (SpreadsheetApp.getActiveSpreadsheet().getSheetByName("total").getRange(challegeDay,3) < curDate.valueOf() ){ } but the output told me yesterday had a...

Google Sheets move cursor onEdit trigger based on cell content

Image
Clash Royale CLAN TAG #URR8PPP Google Sheets move cursor onEdit trigger based on cell content I am trying to write a Google Sheets Apps Script function that checks the content of the current active cell, matches it to the content of another cell, then moves the cursor according to the result of that check. For a spreadsheet as this example one: https://docs.google.com/spreadsheets/d/1kpuVT1ZkK0iOSy_nGNPxvXPTFJrX-0JgNmEev6U--5c/edit#gid=0 I would like the user to go to D2, enter a value followed by Tab, then while the active cell is in E2, the function will check if the value in D2 is the same in B2. If it is, stays in E2. Then we enter the value in E2 followed by Tab, the function checks if it's the same as C2, if it is, then moves from F2 down and left twice to D3. So if all the values are entered correctly, the cursor zig-zags between the cells in D, E and F as shown below: The closest I could find is the answer to the one below, but it involves clicking on a method in the menu e...

Google script. Creat trigger automatically

Image
Clash Royale CLAN TAG #URR8PPP Google script. Creat trigger automatically I am new in js and it is my first script. The idea of my project is creat event in my google calander every time when I edit (write values) to some cell. The problem is that I can't use onEdit() function because I need permission (use calander from sheet level). So I creat installable trigger like this: function createEditTrigger() { var ss = SpreadsheetApp.getActive(); ScriptApp.newTrigger('ToCalendar') .forSpreadsheet(ss) .onEdit() .create(); } Everything is fine but now I want creat this trigger automatically to my sheet not manually like I have now. My idea was to use function onOpen() like this: function onOpen() { createEditTrigger(); Logger.log("hi"); } but it of course will creat many the same triggers. Is there any way to creat trigger automatically only once? I will be grateful for all answers! ...