I just found out that Excel 2013 has a DAYS() worksheet function. It appears to function exactly the same as subtracting one date from another.
One of the blogs I visited said that DAYS() permits you to work with text strings as dates, but I found that text strings also work with subtraction, as in:
="7/15/2016"-"7/1/2016"
which results in 14 when I enter it, which is the same result as
=DAYS("7/15/2016","7/1/2016")
Does anyone know what DAYS() will do that date subtraction will not?
Thanks!
Days can be more dynamic for example you could create a more complex formula with dynamic variables like this =DAYS(VLOOKUP(C3,C5:E16,3,FALSE),B3). In the example you sent it is more common for them to be static. Using the cells themselves can provide a similar function assuming they are in the same date and number formats. So an example using the same formula as above would be =VLOOKUP(C3,C5:E16,3,FALSE)-B3.
Related
I am using excel 2010 and do not have the GetNumeric function available.
I need to get the string from "A1:A200" and put just the numeric value in "B2:B200"
I have tried to use the "Sumproduct but not had much luck.
Thank you for taking the time to check out my question.
For an Excel formula you can use this:
=SUM(MID(0&A2,LARGE(INDEX(ISNUMBER(--MID(A2,ROW($1:$99),1))*ROW($1:$99),),ROW($1:$99))+1,1)*10^ROW($1:$99)/10)
I copied the formula from this website, which also provides other options for returning only a numeric value from a cell.
I was wondering if there was a way to use the CDate function in a countif statement? I'm trying to find dates less than 2 weeks old, am and currently using this statement:
=COUNTIF(CDATE(Table1[Date Closed]),">=" &TODAY() - 14)
I need to turn the Date Closed of the table into actual dates without changing the table (right now they're in the format 13-Mar-2018 but as text format).
Is there a way to do this within the Countif function or am I going to have to do a a VBA code to first change the dates?
Thank you!
=SUMPRODUCT(--(DATEVALUE(Table1[TextDates])>=(TODAY()-14)))
Although I do wonder why you can't have dates as real Excel dates, rather than text strings
Set up your table and insert a column (you could hide the original or place the new column at the end or next to the original) and convert the text date to a date via the DATEVALUE() function.
See reference:
https://support.office.com/en-us/article/datevalue-function-df8b07d4-7761-4a93-bc33-b7471bbff252
You may want to apply format to the new cell/column to look like a date.
Set up your table for "Using structured references with Excel tables."
See reference:
https://support.office.com/en-us/article/using-structured-references-with-excel-tables-f5ed2452-2337-4f71-bed3-c8ae6d2b276e
Count dates based on your condition.
See reference:
https://support.office.com/en-us/article/count-numbers-or-dates-based-on-a-condition-976d0074-245d-49e6-bf5f-1207983f82ed
I'd like to know which column is the last column where the sum of the values of the row is smaller or equal to a given value. (Count the columns until a sum is reached.)
In Microsoft Excel the following array formula works just fine:
{=MATCH(7;SUBTOTAL(9;OFFSET(C1;;;1;COLUMN(C1:G1)-COLUMN(C1)+1));1)}
But Google Sheets always returns 1 as an answer:
=ARRAYFORMULA(MATCH(7;SUBTOTAL(9;OFFSET(C1;;;1;COLUMN(C1:G1)-COLUMN(C1)+1));1))
Is there some difference between Excel and Google Sheets array formulas that I'm missing?
If there is a difference is it documented somewhere?
Is there another way to implement this in Google Sheets (preferably without custom functions)?
Link to sample spreadsheet.
Is there some difference between Excel and Google Spreadsheet array
formulas that I'm missing?
The difference is how specific functions are supported in array formulae. In this case, you're out of luck on two counts: OFFSET can't be iterated over an array (ie it can't produce an "array of arrays" as it can in Excel), and the second argument of SUBTOTAL can't be iterated either; in Sheets, it must be an explicit range.
If there is a difference is it documented somewhere?
No, not that I know of.
Is there another way to implement this in Google Spreadsheet
(preferably without custom functions)?
=ArrayFormula(MATCH(7;SUMIF(COLUMN(C1:G1);"<="&COLUMN(C1:G1);C1:G1)))
I am trying to sum a row biased on the fact that another row has the same month as a variable that is defined by the user. I believe the sumif function would be my best bet but it doesn't seem to be working for me. The row I want it to look at obviously is a row of Date with date formatting (used .numberformat = "ddd mm/dd") but the sumif doesn't seem to be able to pick out the month in each cell. Here is the code I have so far:
Dim cMade As Integer
Dim sDate As Date
cMade = cMade + Application.WorksheetFunction.SumIf(ActiveSheet.Range("B1:RC1"), Month(sDate), ActiveSheet.Range("B30:RC30"))
As you can see sDate is the date that the user imputs via userform then i convert that using dateserial. and B1-RC1 are the dates i want it to look at. And Range B30-RC30 are the sums i want it to grab if the months match up (the reason I have it as + cMade is because it is in a loop that loops through sheets).
Is this code correct? I have been messing with it and looking for alternatives for hours but I cant not seem to come up with anything!
Assuming this is only a part of your code and I may only guess the rest, try the following corrections:
I think you should define Range("B30,RC30") as Range("B30:RC30") - comma here looks like a typo according to the description.
Replace Application.SumIf with Application.WorksheetFunction.SumIf.
As an addition, consider to define ranges more precise, e.g. via Worksheets("Sheet1").Range("A1:C10") or ActiveSheet.Range("A1:C10") syntax. However, this may be an extra measure - I don't see the rest of your code.
Hope that was somehow helpful.
we are looking to find the original? source code for SUMIFS to use in out excel sheet (for both 2003 and 2007. Here is why:
2003 doest support the SUMIFS method
When we do have SUMIFS we cannot utilize formulas "around" the columns (like YEAR())
For example, we want to calculate the ANSWERS that match the YEAR value of the date in cell A1 with the date values in range L:L. Now this doesnt work because we cant use YEAR(L:L) and hence we need to make another column M:M with the YEAR values from L:L
Thus we need the source to be able to upgrade the code further
=SUMIFS(ANSWERS;L:L;"="&YEAR(A1)) <= This works
=SUMIFS(ANSWERS;YEAR(L:L);"="&YEAR(A1)) <= This doesnt
Many thanks
With referenc to these questions:
Replacing SUMIFS in Excel 2003
VBA code for SUMIFS?
I doubt that you'll find the original code, which is, I imagine, C++ and part of the Excel internals. If that's correct, then it wouldn't help much, even if Microsoft gave it to you!
In general, I recommend against using =SUMIF(), =SUMIFS() and other functions that take a string to define the condition for testing: apart from anything else, I'm concerned that they're going to be slow, since my best guess is that internally they construct a string for evaluation for each value. In XL2007 (all I have available right now) at least, this turns out not to be necessarily true (see comments below).
I'm generally much happier with array functions. This, for example, should work in both Excel 2003 & 2007:
=SUMPRODUCT(--(YEAR(L:L)=YEAR(A1)),ANSWERS)
This gets the same answer:
{=SUM(IF(YEAR(L:L)=YEAR(A1),ANSWERS,0))}
In the latter case, you'd enter the formula without the curly braces ({ & }) and confirm it using Control+Shift+Enter to tell Excel it's an array formula.
In the first example, we build a list of boolean results with YEAR(L:L)=YEAR(A1) and convert it into an array of 1s and 0s using the double-negative. Then SUMPRODUCT takes care of the rest. This version requires that ANSWERS has the same dimension as L:L, i.e. it should be the entire column (or the range in L should be constrained in size).
In the second, Excel will run through each entry in L:L. If its year matches that in A1 then the corresponding ANSWERS value will be used, otherwise zero. This formula seems to be more tolerant of dimension differences but I'd still be careful.