I am trying to figure a google sheets problem. I have a master sheet (which is a form response sheet) And I need to copy data to indivdual contractors pages (there are 22 or more individual contractors) Line 22 or next available after line 22) IF Move is selected in F column. I could do this with a query Importrange. The problem is I want this to stay on the sheet it is moved to. So not copied actually moved from the master sheet to the contractor sheet. When the contractors name is selected AND Move is selected in the F column. I do not know how to do that. But I am guessing since there are so many contractors I will need something on the contractors sheet or? a single script for each contractor? or I am over thinking this.
Master Sheet:
https://docs.google.com/spreadsheets/d/1PqXc1XDyhg3nGSia4klxsuoKQtmPcBiDBrgJQr5uwyE/edit?usp=sharing
Contractor Page
https://docs.google.com/spreadsheets/d/1k3as6E30cytNfkzHC55clEH5Jik90aIXOrkgsjRXgEs/edit?usp=sharing
I have tried:
=QUERY(IMPORTRANGE("ID HERE","IN Order!A1:B"),"SELECT * WHERE Col1 = 'Grace'")
Related
There is a table. There is a sheet in the table. Contains 203,354 cells (12 columns and 11962 rows). This sheet has links to cells within the table. Links look like this: #gid=1282039879&range=A41, #gid=1282039879&range=A67:E67, #gid=1282039879&range=A5375:E5375, #gid=1282039879&range=A11780:E11780 etc. Many links, 585 pieces. After copying the sheet, the #gid changes and the links don't work. We need a script for Apps Script that searches for all links on the sheet, determines the current #gid of the sheet and changes it in the links. Manually, this is easily done through "Find and Replace". But it needs to be automated. This script will be assigned to the button.
Table example - https://docs.google.com/spreadsheets/d/1iuPtdWyIo0SRbRrUzTp6hnP-iLn7B764G9j7w7jCkZE/edit?usp=sharing
You can write a script in Python to automate this process. To do this, you can use the openpyxl library to read the Excel file, find all the links in the sheet, extract the current gid, and update the links accordingly.
Here's a sample code that you can use as a starting point:
import openpyxl
# Load the workbook
wb = openpyxl.load_workbook("file.xlsx")
# Select the sheet
sheet = wb["Sheet1"]
# Get the current gid of the sheet
gid = sheet.parent._gid
# Loop through each cell in the sheet
for row in sheet.iter_rows(values_only=True):
for cell in row:
if isinstance(cell, str) and "#gid=" in cell:
# Replace the old gid with the new one
cell = cell.replace(f"#gid=1282039879", f"#gid={gid}")
# Save the workbook
wb.save("file_new.xlsx")
This script will open the Excel file, find all the cells with links, replace the old gid with the current gid, and save the updated file with a different name. You can further customize this script to match your requirements.
I'd like to IMPORTRANGE("http://page","Sheet!A11:F")
Where the page is a link located in a cell on the current sheet, and the range is also in a cell on the current sheet.
For example: IMPORTRANGE("'C8'","'A1'!All:F") Something like that.
My overall goal is to be able to copy the current workbook, add a sheet, put a reference number in A1, then have the sheet automatically pull data (using an A1 vlookup from a master list) from the correct sheet in another workbook without having to manually relink eveyrthing. Just want to put the unique ticker in A1.
The application is there is a 'Master Deal List' workbook. Each row has a different deal with a unique 3 digit 'ticker' in Column A and the deal's sheet in another workbook link in column F. This second workbook (Deals) with distribution data named with the same 3 digit ticker. Finally each investor in each deal has a 3rd workbook which needs to pull distribution amounts from the right sheet in the Deals workbook.
Got it, answer is here:
https://infoinspired.com/google-docs/spreadsheet/dynamic-sheet-names-in-importrange/
Answer:
IMPORTRANGE("http://page", A1&"!A11:ZZ")
I have a spreadsheet to manage my clients. I fill a form and the responses are recorded in a mastersheet from where individual sheets for all clients get populated using script. Now I have another sheet where there is a list of all clients in column A and I want to copy value of h32 from each clients' individual sheet to this list sheet using a script and paste it in the column B next to the clients' name. I also need it to update the value of column b if it changes in the clients' sheet. I need it to ignore the other sheets with specific names like 'Outward' , 'Inward' and 'Payment Details' Sample spreadsheet attached.
https://docs.google.com/spreadsheets/d/1NjWn_6ZfmkRLAJLf0zeBhuKlEP7vWRxOPCyFnRtTeVg/edit?usp=sharing
Do not know where to begin with.
You really don't need script for this. Put this in 'List' B2 and copy down.
=iferror(INDIRECT(""&A2&"!$H$32"),"")
Question is simple. How to get Name (File name in Google Drive) of a spreadsheet using spreadsheet identifier. If you want to know why I need it, you may please continue reading further.
I have created two type of spreadsheets to manage my financial books with my friends, family and business.
Type 1: A book that contains all transactions with a specific person and tells Amount owed or amount lended. I have about 15 of such sheets. Check this screenshot:
Type 2: A sheet named as investments. It fetches data from all other sheets using Sheet Identifier and displays total amount invested or borrowed. Check this screenshot:
In Type 2 sheet, I have programmed and made everything automated. You just need to paste Identifier of any new Spreadsheet in G Column and you're done. Only one thing is Killing me. I am unable to fetch name of the spreadsheet using Identifier. I fetched all records of the sheet using IMPORTRANGE Method, just the file name is not getting fetched. I tried plenty of functions.
Yellow Columns denotes Automatic Columns. I just want to make Column B automatic in case of Type 2 Spreadsheet. It should contain Spreadsheet File Name fetched through Sheet Identifier, same as I fetched all rows of multiple sheets & made calculations within Type 2 sheet. Thanks for considering to help me out.
If I understood your question correctly, you want the name of a Sheets file from the Sheets ID? How about:
var spreadsheetId = 'YOUR_SPREADSHEET_ID';
var sheetName = SpreadsheetApp.openById(spreadsheetId).getName();
I'm pretty new to Google Sheets and I'm looking for a method/function that will allow a button I create to archive all entries in the spreadsheet to another spreadsheet.
I currently have a column that calculates the current week of the year, and another manually entered column that is for the week of the year that the entry was input. This will eventually be calculated automatically on entry of a new row, but what I'm looking to do is pull all entries from weeks prior to the current week and place those rows into another spreadsheet I dictate.
I know this is possible in Excel, but I'm not the greatest with the programming in Google Sheets, so I'm looking for some advice/help.
EDIT:
Quickly I've discovered I'm either REALLY rusty or just not great at Java. I tried the following code:
function myArchive() {
var aYear = getYear()
var sourceSheet = SpreadsheetApp.getActive()
.getSheetByName('Payroll'),
destSheet = SpreadsheetApp.openById('PayrollArchive')
.getSheetByName(aYear),
sourceRanges = ['A:A', 'B:B', 'C:C'],
targetRanges = [7, 9, 12]
.map(function (r, i) {
var sr = sourceSheet.getRange(sourceRanges[i]),
val = sr.getValues();
destSheet.getRange(1, r, val.length, val[0].length)
.setValues(val);
sr.clear()
});
}
Retrieved from here: Is there an easy format to move columns of data by script?
However, I'm trying to do a little different.
I want to copy all entries where column 1 has the week # of the previous week or before. For example, it is currently the 21st week of the year. I want it to pull all entries in the spreadsheet where column 1 is 20 or previous. Not sure how to program the current week in Java.
I want to put ALL information from the rows pulled above into a sheet named the current year in the spreadsheet named PayrollArchive. So, all of the previous weeks' worth of rows would be put in the 2015 sheet in PayrollArchive spreadsheet. I think var aYear = getYear() is the proper coding to grab the current year but is it possible to grab the value of a particular cell in the sheet to get that? I already have the current week # and date information saved in cells within the spreadsheet. The week is saved in J1, and the date is saved in D1:E1 as the last day of the current work week. For example:
=TODAY()-WEEKDAY(TODAY(),3)+6
What happens when we want to archive the last week of 2015 during the first week of 2016? How do we prevent that 2015 information going into a 2016 sheet.
Will this CREATE the sheet if it does not exist? I currently have a 2015 sheet created, but will I need to manually create a 2016 sheet or will the function create the sheet on its own?
To add a custom menu to your spreadsheet, see the documentation:
Google Documentation - Custom Menus
To insert an image, open the help menu:
Do a search on "Insert Image"
You can add a custom menu, or insert an image that is linked to a script. There probably is a function or combination of functions that you could put into the spreadsheet to archive that would get data from the first spreadsheet, then you could copy all the formulas to values. That method would use formulas, then copy the formulas to values. It can all be done in code also, but you'd need to write a script to do that. So it's possible.
See posts like these:
Google Script to copy specific columns from one sheet to another sheet
Move columns of data by script
Copy from one sheet to another sheet