I am new to Google Sheet scripts and attempting to put together something for my business for project management purposes.
On edit, I'm looking to move a row to a new sheet outside the current workbook when a specific name is put in the cell T.
For Example:
if T says "John" - send the entire row to John's Google Sheet by ID
if T says "Amy" - send the entire row Amy's Google Sheet by ID
etc.
You can find an example of the sheet below.
Any and all help is appreciated.
sample spreadsheet
basically, this is the scenario: each of you (you, Amy and John) has own spreadsheet. you as "work assigner" have a master sheet with ID: 11n8TUEiuLLtbyd6ot5imX0zoAOLforHEBnefnHpoZhs (from the example you provided in your question) and all your data are in the sheet called Sheet1 dispersed across the range of cells: A1:AA (also from the example you provided in your question)...
now go to John's spreadsheet and paste this into cell A1:
=QUERY(IMPORTRANGE("11n8TUEiuLLtbyd6ot5imX0zoAOLforHEBnefnHpoZhs", "Sheet1!A1:AA"),
"select * where Col20='John'", 1)
next, go to Amy's spreadsheet and paste this into cell A1:
=QUERY(IMPORTRANGE("11n8TUEiuLLtbyd6ot5imX0zoAOLforHEBnefnHpoZhs", "Sheet1!A1:AA"),
"select * where Col20='Amy'", 1)
note: your spreadsheet can't be private. set permissions to: anyone with link can edit/view
Related
Im trying to make a google sheet were people can enter in data on their own sheet and have the data recall on the main sheet
enter image description here
Basically everyone will have their own sheet with there name on it and they will enter their name on the main sheet. On main sheet it will call all the data from their sheet. People will enter their name on line 2. I want a code that will take name and find the sheet with their name and call in all the data. I tried using =B2!B3 but google sheets thinks I'm trying to find sheet "B2" and not the name in cell B2. how do I get it to call in the name from cell B2
use INDIRECT:
=INDIRECT(B2&"!"&B3)
B2 being the sheet name and B3 = cell or range
spreadsheet demo
I have 2 google workbooks. One is a rate sheet and the other is a vendor list with pricing.
I have the vendor list with pricing workbook linked to the rate sheet workbook via importrage command. This works great and everything updates as it should until you add a new line or remove a line to the rate sheet workbook. At this point the vendor workbook does not update the reference and just still points at the same lines it was originally, now displaying the incorrect data.
How can I dynamically have the vendor list workbook notice the addition or removal of lines in the rate sheet workbook and update the importrange formula?
Can this be done?
Any help is greatly appreciated.
EDIT: I have prepared 2 sample workbooks. They are Test sheet 1 - Rates and Test Sheet 2 Lanes
I have all of our rates in the first sheet. In the second we would have vendor lanes. This sheet consists of multie tabs all with an individual lane that is linked to 1 row in the rates sheet.
In the lanes sheet I have linked the two together via importrange in cell A8. Now this works and links properly, that is until you insert a new line in the rates sheet above the one the lane is linked to and then it doesn't update but shows what the new line information is.
Is there a way to have the lanes sheet dynamically update to the next line when a new line is inserted in the rates sheet?
two sheets links are as follows:
Rates
Lanes
Solution 1 - if you need to check only one condition
To achieve desired result you have to have something like an ID for every rate. For sake of this answer (based on your example sheets) I assume that this could be an Origin City. In Test Sheet 2 I have added new sheet - SheetTest where:
First step
I am looking for the row number where desire City reside in Rates sheet (in example - its Mcclellan city). The code for that is simple:
MATCH(A2,IMPORTRANGE("https://docs.google.com/spreadsheets/d/1JD45y-0-37Kh2KsHnRAMuB0quPtMVuLKuT1qjnNcm1Q/edit","Rates!B:B"),0).
This gives me -> 10
Second step
I use this result to dynamically generate final range - "Rates!A10:X10". The final result in A8 cell is (to make it clearer, I change an address of a sheet to -othersheeturl- :
=IMPORTRANGE(
"-othersheeturl-",
"Rates!A"&
MATCH(A2,IMPORTRANGE(-othersheeturl-","Rates!B:B"),0)
&":X"&
MATCH(A2,IMPORTRANGE("-othersheeturl-","Rates!B:B"),0)
)
Working example
Warning
I see that in your original sheet you use "take" Origin City from Rates sheet, so I remove this dependency in A2 to make it an ID. I hope this solves your problem.
Solution 2 - if you need to check many conditions
An approach is the same, but tools are different. Main goal is to find a row number that meets criteria - "From City" and "To City". Then this row number will be used to concatenate desire range.
First step - some cleaning
To better manage complex formulas its a good idea to divide them into smaller pieces - like in "ordinary" programing. So, we have:
From City in A5
New Albany
To City in B5
Calgary
Rate sheet (external sheet) url in B1:
1JD45y-0-37Kh2KsHnRAMuB0quPtMVuLKuT1qjnNcm1Q
You don't have to put whole URL, only this part is needed
Formula that counts row number that we are looking for in B2
=QUERY(
{IMPORTRANGE(B1,"A1:B"),
ArrayFormula(row(INDIRECT("A1:A"&ROWS(IMPORTRANGE(B1,"A1:B")))))},
"select Col3 where Col1='"&B5&"' and Col2='"&A5&"'
limit 1")
Above code:
Build an array from Rate sheet (external) - columns A1:B and virtual index that represents rows numbers
Then, show only column nr 3 (index) where Col1 matches our "To City" and Col2 matches "From City"
At the end is a limit to only one result (in case that there are more then one maches)
Desire range in B3
="Rates!A"&B2&":X"&B2
Final formula that renders desire data from external sheet in A11
=IMPORTRANGE(B1,B3)
Working example
Final thoughts
You can either hide rows 1-3 or you can pack all above formulas into one. Its up to you. I prefer the first approach.
This solution gives you freedom with as many conditions as you want
More info would be helpful.
A couple ideas:
Using named ranges instead of a static reference. For example, if you create a named range in the rate sheet called MY_DATA that references A2!C600, you can include "MY_DATA" in your importrange in the vendor sheet. Note that you'd still need to update MY_DATA every time you add a row.
If you're importing the entire sheet, perhaps omitting the end row would work (e.g. A2!C instead of A2!C600) - note that this means you need to use filter or query in the Vendor sheet to eliminate the blank rows.
I would like to access data from one Google Spreadsheet on another using strictly formulas.
Currently, I am able to import data using the =IMPORTRANGE(), but need to take this a couple steps further.
The data that I have looks like this:
Spreadsheet 1: Each sheet is for a different day, and has people and the number of fruits they pick from a farm (this is example data). However, the people are not necessarily organized exactly the same way on each day.
Spreadsheet 2: Each sheet is organized by person. Row A has the day (which will be used to lookup from the other spreadsheet), and a function exists in the second spreadsheet to find the persons name (=sheetName()).
What I have so far is [for Spreadsheet 2]:
=IMPORTRANGE(Master!A1, A2 & "!B2")
Where Master!A1 refers to the link of the other spreadsheet, A2 refers to the Day1. However, the part I am looking to replace is the 2 in the B2 to find the row of the person's name in the sheet Day1 from the first spreadsheet.
I feel like I have to do something like this:
=IMPORTRANGE(Master!A1, A2 & "!B" & MATCH(IMPORTRANGE(Master!A1,A2 & "!B1:B100"),sheetName(),0))
, but this gives me the error that it "Did not find value 'Apples' in match evaluation"
Here is the example folder with the two spreadsheets.
https://drive.google.com/drive/folders/0B8lJN2vmKeTBV1JYR2ZoZlVfQUU
All help is appreciated!
I can't find the sample data that you attached but here's what you need to do.
1. Link of the other spreadsheet
2. Name of the sheet to import from
3. =importrange(link,sheet!A:D) [for the sake of an example]
4. =query(importrange(link, sheet!A:D),"select * where Col1 = 'Person's_Name' ",1)
Share a sheet if you are not able to put it together on your data. Cheers!!
is it possible to place the name of the first worksheet in a cell and then use it in a formula to reference information for my second sheet?
I am using Google Spreadsheets, and I have one worksheet that houses scheduling data for employees in columns for each day of the week. The second worksheet builds a payroll report, and directly references columns in the first sheet like so:
='Sales Report - WB 10.06'!B3
My question is, is it possible to place the name of the first worksheet in a cell ('Sales Report - WB 10.06') and then use it in a formula to reference information for my second sheet?
My current issue is that I have to create a new schedule and a new payroll sheet for 10 different regions on a weekly basis, and duplicating and changing the formulas in 70 columns to reference the correct sheet will become very tedious.
It would be much easier to just update a cell in the spreadsheet so that the formulas point to the correct worksheet to reference data from.
Yes, by using the INDIRECT function:
A1: Sales Report - WB 10.06
Then you can use:
=INDIRECT("'"&A1&"'!B3")
Hi just used this with MATCH "=MATCH($C10,indirect("'"&B$4&"'!$A:$A"),0)
Cell B4 is a date that changes, MATCH checks sheet name from B4 (A Date) column A1 to A returning the position of whatever you have in C10
So useful to have a variable as a Sheet name Many thanks.
I need to populate a drop down list in a cell (let's say cell B2) of Spreadsheet A (using data validation) on basis of data located in Spreadsheet B (range - C3:C15).
How do I do that? Googled this for several hours - no luck.
Thank you.
Getting the items from another workbook, as opposed to another sheet in the same workbook is similar. It's a two-step process. First, you need to import the data you want to use for the validation items into the workbook where you want to make use of it, then connect it up as described in #uselink126's answer.
An example: Workbook 2 contains a list of fruit names in no particular order. The list has been assigned a named range Fruits for readability, but this isn't necessary. Workbook 1, Sheet 1 has a column of cells where we want to populate a drop-down with the items from Workbook 2.
Step 1 - Importing the data
Add another sheet to Workbook 1 and insert the following formula into cell A1:
=ImportRange("<key>","Sheet1!Fruits")
where <key> is the unique ID Google docs assigned when you created the spreadsheet. In the example, the items are sorted into alphabetical order as part of the import, and to do this you would enter instead:
=Sort (ImportRange("<key>","Sheet1!Fruits"), 1, true)
The 1, signifies column 1 is what to sort by, true means sort ascending. The cells in column 1 should populate with the sorted fruits.
Step 2 - Point the data validation to the imported list
On Workbook 1, Sheet 1, Select the cells you want to have the fruits as their drop-down data source.
- Right-click the selection and click on Data Validation from the menu. Set Criteria to List from a range and enter Sheet2!A1:A20
That's it. The drop-down chevrons should appear in those cells and when clicked the list of fruits should appear.
Note that this is "live" - adding an item of fruit to Workbook 2's list will also magically add it sorted in the drop-down list.
The format to access cells from another spreadsheet in Google Sheets is:
SheetName!CellAddress
For example, let's say you have a Google Sheet that contains 2 spreadsheets named: Sheet1 and Sheet2 (The names are listed on the tabs at bottom left hand side of each sheet).
In Sheet1 if you wanted to access cell B2 in Sheet2, you reference it by inputting: Sheet2!B2
In Sheet2 if you wanted to access cells C3:C15 in Sheet1 , you reference those cells by inputting: Sheet1!C3:C15
To specifically add cells from another sheet to a dropdown:
1) Select the cell you want the dropdown in
2) Right click on the cell and select Data Validation
3) In the dialog box, click the grid image in the Criteria input box
4) This will bring up the "What Data?" dialog box
5) Click on the tab for the sheet you want to access
6) Hold down shift and click on the cells you want to select (you will see the cell addresses show up in the input box in the "What Data?" dialog)
7) Click OK and you are set. The data will update if you make changes in the source sheet.
More info: https://support.google.com/docs/answer/186103?hl=en
Similar to rossmcm's answer but with a few tweaks because his answer didn't work for me:
=IMPORTRANGE(spreadsheet_url; range_string)
Where spreadsheet_url is The full URL of the spreadsheet from where data will be imported, and range_string a string, of the format "[sheet_name!]range" (e.g. "Sheet1!A2:B6" or "A2:B6") specifying the range to import.
Example:
=IMPORTRANGE("https://docs.google.com/spreadsheets/d/1EwEn_2dSbgAlR7jJ7UT_MyE3h1-Biq3qoovfIGUnVlo/edit#gid=0", "Sheet1!A1:A7")
More info from Google DOCS Help!