I have several worksheets with data that changes each month in new rows. After entering all of the data, I run various analyses that pull specific data from the worksheets. For example, one such analysis looks like:
=MeterReadings!K27-MeterReadings!K26
The columns ("K") do not change, but the rows increase by one each month.
Is there a way that I can simply specify a new row number-- e.g. "x" and "y" -- and have all of the analysis formula automatically regenerate.
Current month: x= 27
Prior month: y= 26
Then
=MeterReadings!K"x"-MeterReadings!K"y"
What you're looking for is the INDIRECT function. It allows you to create a cell reference from a regular string of letters and numbers. Your example might go something like:
=INDIRECT("MeterReadings!K" & CountA(K:K)) - INDIRECT("MeterReadings!K" & CountA(K:K)-1)
Lets assume that the cell a1 is for the value x and cell b1 is for value y,
On c1 enter:
=INDIRECT("MeterReadings!K"&B1)-INDIRECT("MeterReadings!K"&B2)
Related
I hope you are all well.
I have a question. I have a list with many payments listed on column A with dates (format day/month/year) in column B and I would like to use a formula which says something like
IF= A1 = Q2, "pay", "don't pay" , IF= A2 = Q2, "pay", "don't pay"...
Q2 means quarter 2
Could I define names for dates? For example Q2 would be 01/04/2021 - 30/06/2021 so all the dates within that range would be named Q2.
Best regards
You may try anyone of the approaches as explained below, the first one is using ROUNDUP & MONTH Function and the other one is using DEFINED NAMES.
First Approach ---> Using ROUNDUP & MONTH FUNCTION
• Formula used in cell B3
="Q"&ROUNDUP(MONTH(A3)/3,0)
• Formula used in cell C3
=IF("Q"&ROUNDUP(MONTH(A3)/3,0)="Q2","Pay","Don't Pay")
So you can see i have used two columns in the first approach just to make it understandable, therefore just wrap the formula in cell B3 within an IF logic as shown in cell C3 to get the desired output.
Second Approach --> Using DEFINED NAMES & SUMPRODUCT FUNCTION
• Formula used in Defined Names
=ROW(INDIRECT(--TEXT("01-04-2021","dd/mm/yyyy")&":"&--TEXT("30-06-2021","dd/mm/yyyy")))
So you can see I have Defined the Quarter 2 as _Q2 and the reason is a name must either begin with a letter, underscore (_), or backslash (). If a name begins with anything else, Excel will throws an error.
Therefore the formula used in cell D3
=SUMPRODUCT((A3>=_Q2)*(A3<=_Q2))
The above formula creates an array of TRUE's & FALSE's and multiplies to return the corresponding values.
Now the above formula when wrapped within an IF Function it gives us the requisite output as desired,
Formula used in cell E3 (Same it can be done in one cell, to make it understandable i have used two columns)
=IF(SUMPRODUCT((A3>=_Q2)*(A3<=_Q2))=1,"Pay","Don't Pay")
So this is how you can used a Defined names for dates in excel and then use the same within a formula.
This solution does not provide names for dates but it might meet your needs:
Make sure column A is formatted as a date, then use this formula to get the quarter from the month (this array allows you to set Q1 if it is not the same as calendar quarters):
="Q"&CHOOSE(MONTH(A1),1,1,1,2,2,2,3,3,3,4,4,4)
Then test the value of this column:
=if(C1="Q1", "Pay", "Do not Pay")
You could also create a cell at the top of your spreadsheet and name it current_quarter. Then you would type in the current quarter "Q1", "Q2", ... and your formula would be
=if(C1= current_quarter, "Pay", "Do Not Pay")
You are using standard calendar month quarters, so we can get the quarter number easily by dividing and rounding up.
=ROUNDUP(MONTH(A1)/3,0)
You can then use this number in your IF function.
=IF(ROUNDUP(MONTH(A1)/3,0)=2,"Pay","Don't Pay")
I count the number of Excel entries within a date with the following formula (ZÄHLENWENN = COUNTIF)
=ZÄHLENWENN('2021'!L:L;">=01.11.2021")-ZÄHLENWENN('2021'!L:L;">30.11.2021")
The Formula here is working but since I don't want to enter the date values for every month of the year I have created a calculation with the function end of the month. (MONATSENDE)
How do I have to rebuild the formula when I get the two dates from two cells?
Cockpit E3: =MONATSENDE(D3;-1)+1 -> shows 01.11.2021
Cockpit F3: =MONATSENDE(D3;0) -> shows 30.11.2021
Cockpit D3: =01.11.2021 (the only one entered manually)
Unfortunately the outcome of my new formula is 0:
=ZÄHLENWENN('2021'!L:L;">=Cockpit!E3")-ZÄHLENWENN('2021'!L:L;">Cockpit!F3")
What did i do wrong ?
Greetings
You have to put E3 and F3 as references to the formula - not as a string:
=ZÄHLENWENN('2021'!L:L;">=" & Cockpit!E3)-ZÄHLENWENN('2021'!L:L;">" & Cockpit!F3)
Tip: apply a name to E3 and F3 (e.g. FirstOfMonth, EndOfMonth) and then use the names within the formula. It then gets more "readable" - also for someone else who might maintain the project later.
=ZÄHLENWENN('2021'!L:L;">=" & FirstOfMonth)-ZÄHLENWENN('2021'!L:L;">" & EndOfMonth)
And maybe you should consider using tables for sheet 2021 (Einfügen > Tabelle)
In Excel I have a workbook with two active sheets. One sheet is used for raw data (labeled "Data") and the other is simply labeled "Sheet2". 'Data' contains the following information:
Column 1 = County
Column 2 = Street Address
Column 3 = City, State, Zip
Column 4 = Phone Number
In 'Sheet2' I have A1 as a drop down list that pulls off of the County column (Data!A:A). I currently have a formula in place in 'Sheet2' in the A2 - A4 cells. Here is an example of the formula I am currently using in Sheet2!A2 (with similar formulas for A3 and A4):
=IF(A1=Data!A2,Data!B2,IF(A1=Data!A3,Data!B3,IF(A1=Data!A4,Data!B4,
IF(A1=Data!A5,Data!B5,IF(A1=Data!A6,Data!B6,
IF(A1=Data!A7,Data!B7,IF(A1=Data!A8,Data!B8,
IF(A1=Data!A9,Data!B9,IF(A1=Data!A10,Data!B10,
IF(A1=Data!A11,Data!B11,IF(A1=Data!A12,Data!B12,
IF(A1=Data!A13,Data!B13,IF(A1=Data!A14,Data!B14,
IF(A1=Data!A15,Data!B15,IF(A1=Data!A16,Data!B16,
IF(A1=Data!A17,Data!B17,IF(A1=Data!A18,Data!B18,
IF(A1=Data!A19,Data!B19,IF(A1=Data!A20,Data!B20,
IF(A1=Data!A21,Data!B21,IF(A1=Data!A22,Data!B22,
IF(A1=Data!A23,Data!B23,IF(A1=Data!A24,Data!B24,
IF(A1=Data!A25,Data!B25))))))))))))))))))))))))
But the above formula requires me to input another IF formula every time I add a new county. This list continues to grow thus requiring me to frequently update the formula.
I am sure there is an easier way to accomplish what I am attempting to do without the hassle.
Any ideas?
Perhaps something like:
=VLOOKUP(A1,Data!A2:B25,2)
This allows us to avoid a vast array of nested IFs.
I am generating a spreadsheet for a local non-profit that will be used to track sick leave and vacation time. The main data entry page is a calendar that has a row, per month, per employee. This yields a row of cells containing value combinations of the following kinds; V1, JD1, V.5, S1, S.5. These represent the type of time used (V, JD, S, P) and if it is a full or half day off(1, .5).
I would like to create a separate equation for each value, that would check each cell in a range for that value and include only the days with that value and sum them.
How do I check a cell for a specific alpha variable, before including its numeric value in the containing equation's mathematics?
If it is only a 1 letter prefix then this would work:
=SUM(IFERROR(RIGHT($B11:$AF11,LEN($B11:$AF11)-1),0)*1)
For the first line in January, adjust the ranges to suit.
If more than it is a little more hairy:
=SUM(IFERROR(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(UPPER($B11:$AF11),"S",""),"P",""),"V",""),"JD","")*1,0))
For every other option one must put another substitute function to deal with it.
These are Array formulas ans must be entered with Ctrl-Shift-Enter.
If you want each separate then:
=SUM(IFERROR(SUBSTITUTE(UPPER($B11:$AF11),"JD","")*1,0))
=SUM(IFERROR(SUBSTITUTE(UPPER($B11:$AF11),"S","")*1,0))
...
And so forth
If your report is setup as such:
Then you can use the following array formula:
=SUMPRODUCT((Sheet6!$A$11:$A$30=$A2)*(IFERROR(--SUBSTITUTE(UPPER(Sheet6!$B11:$AF30),B$1,""),0)))
Put in B2, hit ctrl-shift-return. Then copy across and down. It will display the totals per. Where Sheet6 is the name of the sheet on which the data is located.
This may have a simple solution which I haven't found yet. but here's the situation.
I have a data in Excel sheet:
This is a log file generated from simulations. The simulation is run tens of times (variable) and each run generates one block starting at "-------------------" and ending before the next "-----------------" divider. The number of rows between these dividers is variable but certain things are fixed. the number and order of columns and the first row & cell being the divider, the next row in the same column having date stamp, the next row having column headings. the divider and date stamp are contained in only 1 cell.
What I need to do is mind the MAX of CNT & SIM_TIME for each simulation run. I will then take the average of these. I only need to do this for the "Floor 1" table from the screenshot.
What's the best way to proceed? which functions should I use? (I have Office 2010 if that has new functions not present in 2007)
General approach, by example:
Data sheet: Sheet1
Results on seperate sheet: Sheet2
Number of rows in data: Cell F2
=COUNTA(Sheet1!B:B)
Intermediate result, Row of data set Cell A3
=MATCH(Sheet1!$B$1,OFFSET(Sheet1!$B$1,A2,0,$F$2),0)+A2
Intermediate result, row of next data Cell B3
=IF(IFERROR(N(A4),0)=0,IF(ISNA(A3),"",$F$2),A4)
Max of CNT data set, Cell C3
=IF(B3<>"",MAX(OFFSET(Sheet1!$B$1,$A3+2,0,$B3-$A3-3)),"")
Max of SIM_TIME, Cell D3
=IF(C3<>"",MAX(OFFSET(Sheet1!$B$1,$A3+2,3,$B3-$A3-3)),"")
Date from data set
=IF(D3<>"",OFFSET(Sheet1!$B$1,$A3,),"")
To expand to give results for all available data, copy range C3:E3 down for as many rows as are in data. any extra rows will show N/A in column A and blanks in others
Screen shot of results:
Screen Shot of formulas:
I am not sure i got what you want to do.
Perhaps something like this would work, although it is not automatic. I am making the assumption that the last value of each simulation is the MAX value.
Put the following formula at cell "I4" =if(B5 = "---------" ; B4 ; "")
Pull the cell formula down till the last row of "Floor 1"
Calculate the average =average(I:I). Don't put this type on column I!!!
Notes
use as many "-" as there are at cell B22
you may want to insert a new column between I and J, in order to average SIM_TIME. The procedure is the same. Only the cells change.
You could easily automate this procedure a little bit with macros.