I am having a lot of difficulty trying to come up with a way to 'parse' and 'order' my excel spreadsheet. What I essentially need to do is get the last non empty cell from every row and cut / paste it a new column.
I was wondering if there is an easy way to do this?
I appreciate any advice. Many thanks in advance!
Are your values numeric or text (or possibly both)?
For numbers get last value with this formula in Z2
=LOOKUP(9.99E+307,A2:Y2)
or for text....
=LOOKUP("zzz",A2:Y2)
or for either...
=LOOKUP(2,1/(A2:Y2<>""),A2:Y2)
all the formulas work whether you have blanks in the data or not......
Okay, from what you've given if I understood correctly, you can use this formula in cell J1 and drag it down for the other rows below this cell:
=INDEX(A1:I1,1,COUNTA(A1:I1))
This assumes that the 'longest row' goes up to the column I.
You can also use OFFSET. You don't need to specify an ending column, you can just reference the entire row.
=OFFSET(1:1,0,COUNTA(1:1)-1,1,1)
Related
I'm trying to count the number of distinct text from a specific date in a data table.
Data Sample with expect result :
I was able to figure out how to count the distinct element from a range I specify, because I can determine the first and last row containing the date.
=SUMPRODUCT(1/COUNTIF(B2:B15,B2:B15))
I have tried to modify my formula so that it determines the cell range by itself but without success.
I searched for an answer, using a combination of CELL and MAXIFS, example below, but Excel does not accept the formula.
=CELL("row",MAXIFS(A2:A15,A2:a15,D2))
I've looked at the INDEX formula, but I can't figure out how to do what I want to do. 😑
Any idea what I'm doing wrong, or what I should be doing instead?
Thanks, I appreciate it!
If you have Office 365 and the new Dynamic Arrays, this sort of formula has become ridiculously easy.
This formula in cell E3:
=COUNTA(UNIQUE(FILTER($B$2:$B$15,$A$2:$A$15=D3)))
Copy down.
You can also generate the unique list of dates with this formula in D3, which spills down automatically and does not need to be copied.
=UNIQUE(A2:A15)
It wasn't easy, but by separating each step of the problem, I was able to solve it.
Note that my solution only works because my dates are sorted.
Here's the final formula in the cell "One formula to rule them all":
=SUMPRODUCT(1/COUNTIF(INDIRECT(CONCATENATE(ADDRESS((MATCH(D3,$A$2:$A$15,0)+1),2),":",ADDRESS(MAX(($A$2:$A$15=D3)*ROW($A$2:$A$15)),2))),INDIRECT(CONCATENATE(ADDRESS((MATCH(D3,$A$2:$A$15,0)+1),2),":",ADDRESS(MAX(($A$2:$A$15=D3)*ROW($A$2:$A$15)),2)))))
Here are my explanations of my process:
Formula if I select the range :
=SUMPRODUCT(1/COUNTIF(B2:B15,B2:B15))
Formula to get the first iteration
=ADDRESS((MATCH(D3,$A$2:$A$15,0)+1),2)
Formula to get the last iteration
{=ADDRESS(MAX(($A$2:$A$15=D3)*ROW($A$2:$A$15)),2)}
Create range from two addresses
=INDIRECT(CONCATENATE(F3,":",G3))
Formula giving me the expect result
=SUMPRODUCT(1/COUNTIF(INDIRECT(CONCATENATE(F3,":",G3)),INDIRECT(CONCATENATE(F3,":",G3))))
I am trying to use a multi-nested conditional Excel formula properly. I think what I have is close but I'm missing something.
=IF(BF6=1,IF(AI6=AI9,IF(BC8=0, 0,1)))
I am not sure I can use AI6=AI9 to specify that the contents of these cells are identical.
Separately, I want this formula to repeat every 7 rows, so I expanded the formula to include the this function:
=IF(MOD(ROW()-1,7),"",IF(BF6=1,IF(AI6=AI9,IF(BC8=0, 0,1)))
Any advice would be appreciated.
Screenshot of problem with new formula: =IF(AND(EXACT(AI6,AI9),BF6=1,BC8=0),1,0)
Image of final formulas that work
In the end, I had to use two formulas in two consecutive cells to make it calculate correctly.
=IF(EXACT(AI6,AI9), 1,0)
=IF((AND(BB9=1, BF6=1, BF9=0)), 1, 0)
I will conquer using IF, AND and EXACT in one conditional formula some other time. Thanks for all the help!
REVISED:
From what I understand, this is what you want. Copy the following formula and paste on cell BB9 then drag the formula down to where the record ends.
=IF(MOD(ROW()-2,7),"",IF(AND(AI6=AI9,BH6=1,BH9=0),1,0))
MOD(ROW()-2,7) is to determine where the result should show. Row() means the current row, and I subtract 2 to eliminate header row and blank row on row 2. 7 is to repeat every 7 rows.
I need a suggestion for regular formula (no VBA/no array formulas) to do the following please:
There is the following dataset:
I need a formula going in the column A and B and returning the month of the first and the second change from 1 to 2 for each row correspondingly.
There are only 1 and 2 being used in the searchable range.
This was really a puzzle :) Please find solution W/O array formula. Make sure you put a number 1 and 2 in cells A1 and B1, because they are part of formula telling which occurrence to take.
=IFERROR(INDEX($E$1:$P$1,1,AGGREGATE(15,6,(COLUMN($E$1:$P$1)-COLUMN($E$1)+1)/($E2:$P2/$D2:$O2=2),A$1)),"")
Without array formulas and pre-calculcations it is very awkward solution
https://drive.google.com/open?id=0B44mzqKXfJYobjNuc0xQRHBaZVU
Use this file for your task. (formulas are inside)
Thank you for + my answer
How do I increment just one number in a formula?
Here is my formula
=LOOKUP(C1-1,B3:B365,D3:D365).
I want to drag the formula along the row so that just the one number increases by one increment for each cell accross.
So the next cell would read
=LOOKUP(C1-2,B3:B365,D3:D365).
Here is a little abuse that will do what you need:
=LOOKUP($C$1-ROW(1:1),$B$3:$B$365,$D$3:$D$365)
assuming you are dragging down.
If you would drag to the right, you would have to substitute ROW(1:1) by COLUMN(A:A)
You can fix rows like this:
...,B$3:B$365,D$3:D$365
Thanks for all you help guys, but the formula requirements changed, but I managed to find out how to do what I needed to do in the end.
I used another cell reference form the row above the formula to increment the part of the formula that required it.
I needed to develop it further though so that the #N/A's were ignored.
The formula eneded up as --->
=IFERROR(LOOKUP($C$1-B371,$B$3:$B$365,$D$3:$D$365),"")
Thanks for all your suggestions though. I find these support communities veru useful and will use them a lot more often in the future.
I am setting up a vlookup to pull product prices from another sheet within the workbook. The code works for the cell but when i try to expand or copy and past the code into the next row it automatically changes the data table_array value.
=VLOOKUP(B5,Prices!1:65536,3)
Within the code i want the first value, B5 to scale with the row it is in, however the second value needs to remain the same. How do i go about doing this? Also is there a way that i can get the cell to remain blank instead of displaying N/A if there isnt a valid part number?
Thanks for your help!
=VLOOKUP(B5,Prices!$1:$65536,3)
The $ lock the range.
For example.
$A1 will lock the column to A when the formulas is copied other
locations.
A$1 will lock the row
$A$1 will lock both the column and the row.
I can't comment because I do not have enough rep but this will fix user3716271 's formula:
=IF(ISERROR(VLOOKUP(B5,Prices!$1:$65536,3)),"", VLOOKUP(B5,Prices!$1:$65536,3))
The following formula should solve both problems as well, a little more compact and would use one less VLOOKUP():
=IFERROR(VLOOKUP(B5,Prices!$1:$65536,3), "")
As guitarthrower had said, the $ before the number is used to lock the range.
For the second part, an IF formula will work fine:
=IF(ISERROR(VLOOKUP(B5,Prices!1:65536,3)),"",VLOOKUP(B5,Prices!1:65536,3)),"")
And if I understand correctly the first part have you tried set an absolute value? Something like:
=IF(ISERROR(VLOOKUP(B$5,Prices!1:65536,3)),"",VLOOKUP(B5,Prices!1:65536,3)),"")