How do I increment just one number in a formula? - excel

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.

Related

Change Cell Reference based on Cell Row/Column Inputs

I have been looking for an answer to this problem. I imagine it's fairly simple, but I think the problem is I don't really know exactly how to search it.
Basically, I want to change the reference in the formula by updating the column and row cells.
So, since the column and row cells say Q & 8, the formula updates to pull from Q8.
If I were to change the column to R, it would pull from R8 and equal 20.
Surely this is straightforward.. right? Please??
Thanks!!
=INDIRECT(ADDRESS(P12,COLUMN(INDIRECT(P11&"1"))))
For explaination how does it work please read about functions INDIRECT, ADDRESS and COLUMN

Is it possible to calculate the sum of a whole row?

I have a file that doesn't have a fixed number of columns.
I was wondering if there is a way to tell excel to put the sum of this row in a specific cell, in a way that each time a column is added to the file I don't have to update the formula and increase the range of the sum.
p.s.
I know I can make it a bit easier by just updating the formula like once in 10 times or so. But I was wondering if it's possible to do it once in a lifetime.
Yes sum(1:1) will sum up all values within the first row.
Keep in mind this does not work if the sum needs to be stored in the same row. As you would create a circularity problem.
If your formula will be in b1, and you want to sum from C1 to the end, then simply:
B1: =SUM(C1:XFD1)
Replace XFD with whatever column you think will be far enough to the right that you'll never have to adjust the formula; or leave it as is.
You could make the range dynamic, with something like:
B1: =SUM(OFFSET($A1,0,2,1,LOOKUP(2,1/ISNUMBER(1:1),COLUMN(1:1))-2))
but since that formula is volatile, it may add excessive time to the calculations.
First: Take note of your first cell (Assumed A1)
Second: Take note of your farthest cell (Assumed AZ1)
Then:
=sum(A1:AZ1)

Excel formula in counting distance between a specific value in rows

I am dealing with unlimited data that keeps adding a combination of rows every-time. I wanted a formula that would count the row distance between the First Lower limit to the Second Lower Limit. Please no VBA i want a formula only or array formula perhaps. I would truly appreciate it if someone could help. I have been trying to figure this out for months now.
Example:
This should work. Paste in cell I2 and commit as an array-formula [control-shift-enter]. Then pull down.
=IF(LARGE(IF((A$1:F$1000=H2),ROW(A$1:A$1000),0),2)=0,0,LARGE(IF((A$1:F$1000=H2),ROW(A$1:A$1000),0),1)-LARGE(IF((A$1:F$1000=H2),ROW(A$1:A$1000),0),2))+1
array formula:
{=SMALL(IF((C:C=E7),ROW(A:A),2^20),1)-SMALL(IF((B:B=E7),ROW(A:A),2^20),1)+1}
fill up and down.

VLOOKUP a value to the left of the Lookup_value

Using Excel, is there any way to use the VLOOKUP function to find the date corresponding the minimum and maximum values?
With your layout #Mark is correct (you can't) and for the reason stated. INDEX/MATCH may be a suitable alternative but to provide some detail, please try in say I30 copied across and down to suit:
=INDEX($H$6:$H$26,MATCH(I27,I$6:I$26,0))
No, there is no way to look left using VLOOKUP - it can only look right. You should look at INDEX/MATCH combo to solve this.
If you're willing to use a helper column to hold the date, you can. In my example I added the helper column in column N. So column N also displays the date from column H.
=VLOOKUP(I27;$I$6:$O$26;7;0)
=VLOOKUP(I28;$I$6:$O$26;7;0)
...
There is an easy solution for this - if you don't insist on using VLOOKUP() :-)
Above your row 27 enter a new row, repeating the column headings ("Thomson" etc.). You can just use =I5, =J5 and so on.
Now enter this formula in I30: =DGET($H$5:$N$26;1;J27:J28) ... and drag it to the right.
For the maximum values you need to repeat the column headings just above the "maximum" row again.

Getting the last non-empty cell in a row

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)

Resources