I'm pretty new to Excel, and one of my bosses (who knows even less about Excel than I) is asking me to create a spreadsheet that will track a bunch of different deadlines. For quick reference, I need to use conditional formatting to do the following:
Highlight only non-blank cells that contain a date in the past.
Highlight with a color scale cells containing dates between now and now+90 workdays.
Nothing I've tried is giving me the results I need. I'd appreciate any guidance, as I'm getting very frustrated and this is fairly time-sensitive.
I will answer your second question. I think you will be able to answer the first one yourself from what you learn from the second one.
The executive summary is: use a combination of TODAY() and WORKDAY().
Now for some useful detail.
First, I suspect (from your reputation) that you are new to StackOverflow. Welcome! Take a look on the right side of this page. At the bottom there are "Related" questions. I obtained the following one from there. It is half of the answer to your question. The key point is to use the TODAY() function in your formula.
Second, the WORKDAY() function, with a positive number n, provides a date n workdays into the future. You may also need to make adjustments if your company's calendar is different from the canonical one.
You may want to set a cell in your spreadsheet to the date returned by =WORKDAY(TODAY(),90). Lets just pick A1 for simplicity of explanation. When you first add that formula, you will get what seems like a nonsensical number. Change that cell's format to date and it will make sense.
Now you can refer to A1 in your conditional formatting, as in the "less than" highlighting rule. That should do it.
P.S., while you are at it, search for "named ranges". As a beginner, it is probably the most useful "trick" you could learn. Then name whatever your A1 cell turns out to be something meaningful, like ninetyWorkdaysAhead (you cannot start a named range with a number), then refer to that name in your rule. That way, if you need to move it, your code will not break.
Related
I am a programmer, so please bear with me. I understand that Excel isn't necessarily what I am used to in other domains, but I'm cracking my head open on how to accomplish something that seems somewhat simple.
I have a column of numbers that are themselves the basis of a formula. I want to filter those cells based on some criteria and pass them to another function to perform a calculation.
I understand that this can be done with "filters" in the excel sense. This would mean I would have to click multiple times for each calculation, filter the results, copy the value and paste it where I need it to be. If the data ever changes, I will have to do it all again.
What I am looking for is the equivalent of filtering in a programming language, here's an example:
let range = [1,2,3,4,0,-1,-2,-3,-4];
let subrange = range.filter(function (cell) { return cell > 0; });
subtotal(1,subrange);
So what my excel is like.
I have a column G, that has 12,000+ results in it, each one of these columns is like this:
=(En-Bn)/Bn
These are copied down, n means the row number from 5-12,000+
Now I would like to create a cell, M2 such that it contains:
=SUBTOTAL(1,[ Gn in G5:G12000 where Gn > 0 ])
The goal is that I do not want to have to point and click, because actually, there are many more cells I need to create (about 20) with similar kinds of "filter" predicates.
It would be nice, as much as possible, if I also don't have to specify the n...n-1 range of the column, as ideally that can change. Could be 10, could be 20,000, shouldn't matter.
The best formula or solution would be like:
SUBTOTAL(1, [ Gn in G0:GLENGTH where Gn > SOMECELL ])
Any pointers, or suggestions where to read, or a solution would be awesome. I've been searching on google, and it seems that I lack the right understanding to find the answer in the material presented.
Also, please excuse me for using programmer speak, I know that Excel formulas are not necessarily a 1:1, I'm just looking for a way to save time. Answers in VBA or using Macros are welcome, the main thing is to find a way to do it...
Best,
Jason
Update
I should specify that it needs to be a bit backwards compatible, so I can't use the FILTER function that is only available in >= 365
I'm not at all sure that your attempts at saving time by talking in programming language instead of English really saves either time or space. My best effort determines that you got us all confused. Please tell me why the simple formula below doesn't work.
=AVERAGEIF(G2:G15000,">"&A1,G2:G15000)
This formula requires A1 to hold a number and the formula supplies the > sign. A variation would have A1 contain both, number and comparison, like >1.2`
=AVERAGEIF(G2:G15000,A1,G2:G15000)
The above formulas start the range at G2. Change to G5 if that is what you need. G15000 is a random number intended to be larger than anything you will ever need. The function ignores blanks. However, if you are worried about having a sheet with 16000 rows just on the day you forgot where to adjust the formula I would recommend the use of a named range which you could format to be dynamic.
Named ranges are neater to handle than range addresses and names can be given descriptively, such as HourlyReadings. The above formula would then look like this:-
=AVERAGEIF(HourlyReadings, ">"&A1,HourlyReadings)
Theoretically, the formula by which HourlyReadings is defined could also be written into the worksheet formula but it would become unwieldy. As shown above, you would have to look into the Name Manager to know if the range is dynamic or not but, of course, once defined you can use the same name in many functions and formulas which saves a lot of maintenance time.
This is for Excel 365, using worksheet formulas. With data in column G starting in G5, in another cell enter:
=SUM(FILTER(G:G,G:G>0))
How about an array?
=SUM(IF(G:G>0,G:G,""))
put cursor in 'function bar' with formula. Then press CTRL+SHIFT+ENTER (in that order while holding them all down. {} will appear around formula.
Let me know if further assistance is needed.
Matt
First time asking a question and very new to VBA code. I'm trying to write VBA code to highlight when dates overlap across a range of cells based on a unique identifier. Here is an example of the code:
Basically i'm looking to compare the dates associated with the first unique identifier (1234 - which is three rows), highlight whether any dates are overlapping and then move to the next unique identifier (5678) and do the same.
Hope this is clear. Any help is appreciated.
CiarĂ¡n
welcome to SO!
You did forget to include the VBA you already wrote yourself, as that would help people here helping you (and this is not a free coding service platform ;)). Secondly, you could do that without VBA, just using the COUNTIFS formula and conditional formatting. For that solution, see e.g. this tutorial on COUNTIFS: https://exceljet.net/excel-functions/excel-countifs-function and this one on conditional formatting: https://exceljet.net/conditional-formatting-with-formulas
I'm making a summary of a list of tasks, and the corresponding dates (start date, first answer date, ...).
It looks more or less like the following:
Title Start date First answer
Task1 29/06/2018 02/07/2018
Task2 09/05/2018
Task3 13/06/2018 14/06/2018
I would like to calculate the average time, needed for the first answer to be given. In case no first answer is given yet, this entry needs to be ignored in the calculation of the average.
In order to be able to understand the formulas better, I've decided to use names for the headers, like:
Name "Header_Title" has value "Title"
Name "Header_Start_Date" has value "Start Date"
Name "Header_First_Answer" has value "First answer"
Also, the number of entries, defined as COUNTA(OFFSET(Header_Title;1;0):A1048576) has a name: Total_Count.
Next to that, I've created names for the ranges of the column values:
"All_Start_Dates" is defined as =OFFSET(Header_Start_Date;1;0):OFFSET(Header_Start_Date;Total_Count;0)
"All_First_Answered" is defined as =OFFSET(Header_First_Answer;1;0):OFFSET(Header_First_Answer;Total_Count;0)
Explanation : take the first entry under the header (column title) and go to the row, corresponding to the last task.
This makes it very easy to write a formula for calculating the average difference between those date columns:
{=AVERAGE(All_First_Answered_Dates-All_Start_Dates)}
// mind the {} for showing this is an array formula
Now the problem is: how to use the AverageIf worksheet function in order not to take into account the cases where First answer is not filled in?
I already tried using ">0" and ">"&0, but this does not work, the formulas are said not to be valid:
{=AVERAGEIF(All_First_Answered_Dates-All_Start_Dates;">0")}
{=AVERAGEIF(All_First_Answered_Dates-All_Start_Dates;">"&0)}
Does anybody have an idea?
Thanks in advance
P.s.1. As you can see, I'm using cell range A1048576 as the last entry of column A, does anybody know a more elegant way to describe this?
P.s.2. One extra thing, which would make my life easier, is the possibility to see which cells have a name (I was thinking about conditional formatting, but I didn't find the way to do this). Does anybody know if there is a way to highlight individual cells, linked to a name?
So my suggested answer would be
=AVERAGEIF(All_First_Answered,">0")-AVERAGEIF(All_First_Answered,">0",All_Start_Dates)
I'm assuming here that all start dates are present but first answered dates may be missing: you could easily add an extra condition for start date if you used AVERAGEIFS. Both parts of the formula include the same conditions so they are working on the same rows.
The intermediate columns above are just included by way of explanation.
Try an array formula.
If you're not familiar with array formulas, the significant difference is you press and hold Ctrl+Shift then hit Enter instead of just pressing Enter. You will see the formula preceded and followed by curly brackets. Do not type those. Those will appear automatically.
=AVERAGE(IF(INDIRECT("C14:C"&LOOKUP(2,1/(A:A<>""),ROW(A:A)))=0,"",INDIRECT("C14:C"&LOOKUP(2,1/(A:A<>""),ROW(A:A)))-INDIRECT("B14:B"&LOOKUP(2,1/(A:A<>""),ROW(A:A)))))
This seems to be so simple of a request, but I was not able to find an answer. I have a numeric cell and it seems to round numbers. Can I ask excel to tell me formatting settings of a particular cell. For example if the number formatting is fraction up to one digit I would like to know that. It would also be nice to know what the other attributes are; like width, centering, and so on.
You can get some information using the cell function (doc), but it's not as useful as one hopes...
You need to use VBA for more details.
I would like to have part of an excel formula be dynamic, other than a cell reference.
For instance, suppose that in column A (cells A1:A99) I have a bunch of numbers, and I want to know how many of those numbers are greater than 50.
If I wanted this calculation to be static, I could simply use one of the following:
=COUNTIF($A$1:$A$99,">50")
=SUM(IF($A$1:$A$99>50,1,0))
=SUM(($A$1:$A$99>50)*1)
I mention all three because my actual formula is hairy and a bit of a mix of the second and the third. (After all, perhaps something will work with COUNTIF but not with the others.)
Now, I want to be able to type my condition in another cell (say C1). So if I type ">50" in C1, my calculation will be as above, but if I type "<100" I will count how many entries of column A are less than 100.
Is this possible? (I am using Excel 2003 on Windows XP.)
There may be something that I'm missing.
If you give
=COUNTIF($A$1:$A$99,C1)
in any cell, and then in cell C1 you type >50 or <100
don't you get what you want?
Use INDIRECT
=INDIRECT(COUNTIF($A$1:$A$99,">50"))
is same as
=COUNTIF($A$1:$A$99,">50")
But, as you identified, the former, you can generate within the excel cells! I do it all the time, for such things.
I usually solve this by adding another column carrying the result of a complex logical expression, like
=AND(OR(C3<D3;E3>=100);A3=VLOOKUP(B3;Sheet2!$A$2:$B$212;2;FALSE))
this formula is in all rows of -say- column F - note: no IF needed here!
then I calculate a complex conditional sum across column E using =SUMIF() like
=SUMIF(F2:F57;TRUE;E2:E57)
I know that some users say "I do not want to change my design. That's ok; my argument is that I have better control over the condition, I can work on the condition seperately from summing up or other functions that rely on that condition, and I can filter records for TRUE or FALSE to look at the subsets and have a rapid overview if the formula makes sense
hope that helps Good luck MikeD