I need to create a script or a macro that can basically copy data from particular columns in sheet 1 to sheet 2 when you select an item from a drop-down in a column in sheet1.
I have a google sheet that has patient info and their medical procedure in tab 1, 15 columns. When a user select "Completed" from the dropdown menu in column 6, I want the data in the first 4 columns of that row to be copied in tab 2.
Is there a plugin available or do I need to write a script?
Try the the moveRowsFromSpreadsheetToSpreadsheet_ script. Follow the instructions in the script to set the parameters and install it in your spreadsheet.
Some of the best resources for learning Google Apps Script include the Beginner's Guide, the New Apps Script Editor guide, the Fundamentals of Apps Script with Google Sheets codelab, the Extending Google Sheets page, javascript.info, Mozilla Developer Network and Apps Script at Stack Overflow.
Related
I have a Google Sheets spreadsheet with several tabs. Data is written to the 'tracker' tab constantly by a script which is writing information from incoming files. So new rows are constantly being added.
The tracker tab has a number of 'filter views' built using the UI. The data range that these filter views point to does not update when new rows are added.
I have seen some scripts which seem to be able to update the range if usng the Google Sheets API. However, I need something that runs within Google Apps Script itself..
Can anyone help?
The answer was to add the Google Sheets API via the add Services menu.
Is there any limit of data between Google Sheet and Google Script?
I know about quotas of apps script, my question is if a limit of the number of rows exists when you edit a big google sheet from Google apps script.
My problem is:
I take like 1000 rows x 30 cols from Google Sheet with SpreadsheetApp and i put that in an Array is Google Apps script, then I make some conditionals in Javascript to detect some stuff, and then I edit that sheet (with 1000 rows x 30 cols) with google apps script and SpreadsheetApp. My script works well many months with data like 200 rows x 30 columns but now with x5 data my script is failing. The script is not reporting an error, it just make the edition really wrong. It would be possible the amount of data?
I haven't seen this happen, but I can't ensure that this isn't a bug. If you have a Workspace account you can contact Google Workspace Support and ask them to take a look into it.
I have an active spreadsheet, I want to select a cell in this spreadsheet and then bring me to another Spreadsheet. I used app.openByUrl to open the spreadsheet and then get my wanted sheet by name and then activate the cell by getRange, the script is finished but it didn't take me from the active spreadsheet to the other spreadsheet, the cursor remains in the cell of the active Spreadsheet. I use the following code. Does anyone has an idea?
app.openByUrl("https://docs.google.com/spreadsheets/d/1S9Kc6foLZ_bXqs4/edit#gid=502179704").getSheetByName("Verification Candidates").getRange('D4:F4').activate();
It's not possible to activate an external spreadsheet by solely using Google Apps Script as
Class Spreadsheet doesn't include like similar to Class Range activate
The Class Spreadsheet "open" methods open the spreadsheet on the server side, not on client side.
You might be able to do what you are looking by using other tools (i.e. a complex bookmarklet)
I'm using Spreadsheet and Apps Script to manage clients and billing.
To achieve this, I have a Spreadsheet containing all data and a Spreadsheet used as model that I duplicate for each project.
When creating the project (using Apps Script), I fill a cell with an IMPORTRANGE function.
The "problem" is that once the project is created and cells filled, I need to select the cell containing the IMPORTRANGE and "Allow access" to connect the other Spreadsheet.
Is there any way to ask the user to "Allow access" using Apps Script so the user won't have to do the step described before?
Edit:
=INDEX(
IMPORTRANGE("https://docs.google.com/spreadsheets/SPREADSHEETID"; "SHEETNAME!$A:$A");
match(L13;
IMPORTRANGE("https://docs.google.com/spreadsheets/SPREADSHEETID"; "SHEETNAME!$B:$B");
0)
)
I use IMPORTRANGE to display a cell in the other Spreadsheet based on a cell in the current Sheet. Using this method allows me to always have the cell up to date without having to restart the script.
I'm trying to find an Employee ID from the attendance which spans multiple sheets and pull the timestamp into a single sheet.
The Google sheet has multiple sheets in it. There are individual sheets for every working day:
Each attendance sheet has two columns. In order to know all the times of the employee's login I want to pull in all the occurrences of the employee ID from all the sheets and along with its timestamp to the Consolidation sheet: .
I've done a similar thing in Excel and guess can be done in Google sheet using Google Apps script.
It would be helpful if someone can guide me to a built-in or custom function in google sheets.
I'll help you with a basic outline, some advice, and some resources to help, but don't expect me to write the whole thing.
Step 1 - Create a custom menu option
You'll want to be able to access you script from the spreadsheet. You can accomplish this by creating a custom menu option. Here's an article by google on custom menus.
Although google uses the simple trigger onOpen, I've found installable triggers to be more reliable.
Step 2 - Get user input
It would be nice to be prompted for the id of the employee and have the script work it's magic. Here is an article by google on dialogs and sidebars that discusses how to get user input for a script.
Step 3 - Read and write data from the spreadsheet
You can access spreadsheeet data with the SpreadsheetApp. When calling your script from a custom menu, you can use SpreadsheetApp.getActiveSpreadsheet; however, if you want to test your code in the script editor, there is no "active spreadsheet", so use SpreadsheetApp.openById instead.
With access to the spreadsheet, you can call:
spreadsheet.getSheetByName("name").getRange(1, 1, 2, 2).getValues();
spreadsheet.getSheetByName("name").getRange(1, 1, 2, 2).setValues([[1, 2], [3, 4]]);
Note that getValues and setValues work with 2-dimensional arrays
WARNING - As usual, I/O takes a lot of processing time so avoid superfluously calling getRange().XetValues, this google article about appscript best practices goes into more detail. Also, if you have a LOT of attendance sheets, then you may want to consider condensing them into one.
Step 4 - Get the appropriate sheets
You'll need someway to distinguish which sheets in the spreadsheet are attendance sheets:
function isAttendanceSheet(sheet) {
return /Magical regex/.test(sheet.getName);
}
var sheets = spreadsheet.getSheets().filter(isAttendanceSheet);
Come up with the magical regex that works for you, and this will filter them.
Hope this helps and good luck!