I have two Google Sheets (separate documents) that contain information, let's call them Master & Source. Within Source I have an undefined range of cells that are in sorted order by date that I need to display within Master. Master is intended to have links to all the various Source sheets, in normal operation, I'll have multiple of these, so I can view all of the quick information about all of the Source sheets displayed conveniently in Master. Master contains a date range that starts before and ends after the date range from within Source (to accommodate other date ranges from other Source sheets).
My goal is to create a single cell formula that can be copied and pasted for each Source that I need to view in my Master that would fill the cells in columns before and after the date range from Source with the string "No Class" and all the cells that match the date range from Source would simply be a copy/reference to the matching cell from Source. This is the formula I came up with:
=ARRAYFORMULA(if({A1:Z1;A1:Z1;A1:Z1;A1:Z1;A1:Z1}<importrange(Link!B4,"Source!A1"),"No Class",if({A1:Z1;A1:Z1;A1:Z1;A1:Z1;A1:Z1}>Link!N4,"No Class",importrange(Link!B4,"Source!A1:Z99"))))
Link!N4 = Start Date
Link!B4 = hyperlink to the google sheet `Source`
Amazingly, it works quite well, except for one major drawback: the array of values from importrange are relative to the cell that the formula is in - aka, the range from Source starts at Master!A1 rather than starting at the first column that has the same date as Source!A1.
This is a screenshot of the result of my formula in Master. *EDIT: No Class has conditional formatting to make the font color match the fill, so you can't see it in this screenshot, but they are the dark grey cells.
And another screenshot, this time of the Source I'm trying to view.
I realize this approach might not be the only way (or might not work at all) but each time I try something else it always comes down to the same problem: how do I dynamically start the importrange at the first column that matches the date from Source using a formula that is in the first cell?
I found an acceptable workaround. This is by no means a solution to the problem of trying to offset data within an array, but it allows me to get what I needed to be done. This code needs to be filled using the fill handle (blue square on the bottom right of the selected cell). I'm adding this here in the event someone gets in a similar situation and needs an alternative way to look at the problem.
=iferror(if(importrange(Link!$B4,"Source!A1")>A2,{"No Class";"No Class";"No Class";"No Class";"No Class"},if(importrange(Link!$B4,address(1,COLUMN(A3)-match(importrange(Link!$B4,"Source!A1"),$A2:$Z2,0),4,TRUE,"Source"))=A2,importrange(Link!$B4,address(2,COLUMN(A3)-match(importrange(Link!$B4,"Source!A1"),$A2:$Z2,0),4,TRUE,"Source")&":"&address(5,COLUMN(A3)-match(importrange(Link!$B4,"Source!A1"),$A2:$Z2,0),4,TRUE)),"No Class")),{"No Class";"No Class";"No Class";"No Class";"No Class"})
A2 is the date of the column in master I'm trying to import into, it changes as your drag the fill handle.
A3 is the cell that the formula is currently in
This works by first checking iferror (but I'll come back to that).
Then, if the date in the same column as the formula is less than the start date "No Class" fills the column (hides dates prior to start date)
ELSE If the date in the same column as the formula is the SAME as the date in the column of the Source (offset by the number of columns away from the start date) then fill the column with the corresponding column from Source (aka, this fills one column at a time, rather than importing the entire range at once).
(Back to iferror) An error is returned for any columns that come after the end date - so iferror fills those columns with "No Class"
Related
I'm relatively new to using google sheets and formulas and what not.
I am trying to highlight a row of cells using conditional formatting based on whether or not a name and date are both present in another range of cells.
In the case of the names, I need an exact match which I have figured out already easily enough.
In the case of the dates, I need it to highlight only if the leftDate is less than(prior) or equal to the rightDate displayed in another range of cells.
For example,
Names and Dates
In the left section of the sheet, the row containing Jacob should be highlighted due to his name being present in the right section of the sheet AND the date being prior.
Where as Nicks row in the left section of the sheet would not be highlighted due to the date being after.
Andrews row on the left would be highlighted due to having the same date.
Mikes row would not due to his name not being present on the right section.
so far for comparing the names I am using a COUNTIF function, and to enable both names and dates to function I have it nested in an AND function, like so
=AND(COUNTIF(leftNames = rightNames),COUNTIF(leftDates>=rightDates in relation to name))
The name portion works it is the date portion I am struggling with, sorry for the long winded explanation. Any help is appreciated!
Thanks
try for range A3:D:
=INDEX(IF($B3<VLOOKUP($A3, $F$3:$G, 2, 0), 1,
MATCH($A3&$B3, $F$3:$F&$G$3:$G, 0)))
I'm new to Excel, so please be patient and kind.
In cell G3, I have a triggering date entered (example: 10/02/2018). In cell H3, I have entered the formula, G3+15, with the result being 10/17/2018. The formula in cell I3 is H3+15, with the result being 11/01/2018. This continues along the row until I reach 90 days from the triggering date of 10/02/2018.
When I copied the formula down the columns, the cells read across the row as 01/15/1900, 01/30/1900, etc.
How do I keep the formula set behind the scenes, so to speak, but keep the cells empty of data until the triggering date is entered in column G?
The triggering date will be entered as needed based upon specific events.
Thank you for reading and your suggestions.
Dana
You could use a simple IF statement. In H3 use the formula:
=IF(G3="","",G3+15)
This formula can then be dragged to the right/copied to the right to give you the number of columns you need.
The way this works is by validating the contents of G3. It is asking "Is cell G3 empty, if so, then return nothing; if not, do the math."
I've seen lots of answers for various other conditions under which to do this. However I can't seem to modify any of these to work for a date range. What I want is for the column color of column E to change if the date in column H is between today and 5 days from today.
I've tried varying versions of this formula: H3:H150 =today() +5 with no success
This doesn't give me the range of between now and 5 days from now but I could do multiple rules like this and just go down on each one(=today() +4, =today() +3, etc) but obviously I need this rule to work first.
Thanks!
Conditional formatting is more helpful than you seem to be expecting. Clear formatting from the column to be formatted, select it and Format, Conditional formatting..., Format cells if... Custom formula is and:
=and(H1>today(),H1<today()+6,H1<>"")
Then select fill of choice and Done.
This should format the next five days (change the angled brackets around for the past five days).
Setting the range is achieved with selection of the column to be formatted (not the one with dates in it - H). If only to apply to Rows3:150 (and in general it is a good idea, for speed of processing, to restrict the ranges to which CF is applied) then either start by selecting Rows3:150 in the column to be formatted (instead of the entire column) or adjust the Apply to range for the rule, but in either case use H3 in place of H1 in the formula above.
CF should automatically apply the rule as written to the first row in the selected range and then adjust it for the second and subsequent rows in the way copying down would adjust the formula (if at all) were it in a cell in the sheet.
I am using Google Sheets and trying to write a custom formatting rule that seems like it should be simple. I am trying to figure out how to conditionally format all the cells in a column INCLUDING AND ABOVE (but not below) the cell that meets my condition.
I've found a lot of things that will format the entire column, but that's not what I'm looking for.
The image below is a basic example that I manually colored in to do what I want.
It's for my budget spreadsheet, where each row is an entry from a particular date. I have an "Agreement" column that is empty except when I enter the date that I reconciled the budget. I want it to color that cell and all the empty cells above it green, signifying at a glance: "everything up to this point is ok/has been checked over". Then as time goes by, and I enter another date several rows below, I want it to extend the colored shading up to there.
I've been searching, but it is hard to articulate this; if I say "until this cell" I get results for "shade cell until text is entered"; any mention of "above" and "below" generally relates to the values in the cells; I've found some things about Indirect but just for a single cell above, not for all cells above the current cell.
Wondering if this is even possible...
Google Sheets example
If you create a conditional formatting rule for column A using a Custom Formula you can use this formula:
=COUNTIF(ROW(),"<="&LARGE(ArrayFormula(IF(ISBLANK(A1:A100),"TRUE",ROW(A1:A100))),1))
The larger the ranges you use, the slower it will be however.
I am usually good with conditional formatting in excel/google sheets, but here is my current challenge. I am needing to format specific cells based on the data in a table at the top of the sheet where the row used for comparison changes based on the value in one cell. Here is the link to the sheet I am currently working on.
https://docs.google.com/spreadsheets/d/1t7pgvGjxs1Eb3cCcRnLDA6E9ov5riEDAjn-fX3A0s8I/edit?usp=sharing
-The table at the top of the is the reference table and does not change.
-the number in column E is the data that determines which row of the table to compare the data in columns G through AN
The Situation:
Let's look at Name 3.
The numbers in G18:AN18 are compared to the G12:AN12 because of the matching number in E18 and E12
If the number in G18 equals G12 - no formatting change
If the number in G18 is one less than G12 - fill color Yellow
If the number in G18 is more than one less than G12 - fill color Red
This is true for each cell in row 18 columns G:AN
- That's the easy part -
Now, when the number in E18 changes (from "9" to "10" for example), I need it to stop looking at row 12 and now look at row 13 because E18 now matches E13
I know that I can do it using nested IF/AND statements but I would have to do it for each and every cell individually. How can I do this more easily through google sheets?
You need to use INDEX/MATCH, so for the yellow formatting starting in G16:-
=G16=INDEX($G$4:$R$14,MATCH($E16,$E$4:$E$14,0),COLUMN(A:A))-1
The idea is that as you copy it across the column changes to B:B etc. so you get the next column of the top region and as you copy it down you get whichever row matches E16, E17 etc.
I'm sure you can modify it for the red formatting and also to take account of any blank cells.
Also, in this particular case that the numbers in E4:E14 are just the numbers 1-11, you could use E16:E25 to index directly into G4:R14 and make the formula a lot simpler like this:-
=G16=INDEX($G$4:$R$14,$E16,COLUMN(A:A))-1