EXCEL: Auto number rows until value in cell - excel

This is probably very easy, but I can't seem to get it to work.
I'd like a formula for autonumbering rows based on the value in B1.
Starting from B1 id like to autonumber rows from 1 and down until the value defined in B1.
This need to be a formula, and not VBA beacuse of other technical obstacles cannot solve.
I manage until I reach the defined value (blank) is returned, and the next row returns #VALUE because the calculation fails.
I have tried all the IF, IFS, <>"", <=, >=, AND, OR combinations I can think of.
How can I define this and avoid the #VALUE error.
The defined value in B1 will be a value ranging from 6 to 48
Would really appreciate help on this.

If you have Excel 365 you can use SEQUENCE:
Put =SEQUENCE(B1,1,1,1) in the cell below Month
The values will spill down - that means there have to be enough empty cells below the formula cell
This will create a numbered sequence --> number of rows is set via value in B1, one column, starting at 1

Related

How to find last number in row minus second to last number in row

I have a spreadsheet that I'm using to try and keep track of google keyword rankings, but I can't figure out how to track the last change in keyword ranking, meaning the last cell in the row MINUS the second to last cell in the row. I've included a picture on what I'm trying to accomplish. The formula would take, for example, in J3-I3 to get the last change of 4 shown in D3.
Right now I have this code:
=(LOOKUP(2,1/(3:3>0),3:3))-LOOKUP(9E+300,B3:INDEX(B3:J3,MATCH(9E+300,B3:J3)-1))
Which is fine, but I need to keep changing the cell references is. Is there any easier way to accomplish this?
You can use just INDEX(MATCH()) and refer to the full row.
=INDEX(3:3,MATCH(1E+99,3:3))-INDEX(3:3,MATCH(1E+99,3:3)-1)
If you have, say, 12 columns B="Jan" to M="Dec" with a formula in each, and you need to calculate the difference between the latest month's value and the previous month's value, the formula above does not work if any columns are blank but with formulas, or until you have a value for each of the 12 months.
If you want to calculate, say, Jun minus May when Jul to Dec are blank except for their formulas, this formula (for row 4) will do it for whatever the latest month with a numerical value is:
=INDEX(4:4,MAX(IF(ISNUMBER(B4:M4),COLUMN(B4:M4))))-OFFSET(B4,0,SUM(IF(ISNUMBER(B4:M4),1))-2,1,1)
It must be entered with Ctrl+Shift+Enter.
#ScottCraner has provided an answer with the right logic, which is to
locate the second last and last number in each row, and then perform a
simple subtraction between the two.
INDEX+MATCH is one way of solving the question, but in this case, given that all data are stored in a table, and to add the flexibility of
1) moving the table around or across worksheets;
2) entering numeric value in the same row outside of the table;
without incurring errors, I've used OFFSET+COLUMNS instead.
Please note in my example I have given a name to the table, called it Tbl_WordRk, and I have added some data (in the gray area) for testing purpose.
Basically, OFFSET works in similar logic as INDEX, with a known starting point (such as B3 in my example), it will find the value (or even a range of values) in another row or column as long as you know the relative position of the value compared to the starting point. For example, if your starting point is cell A1, the following OFFSET function will return the value in cell D8.
=OFFSET(A1,7,3) which is interpreted as 7 rows down and 3 columns to the right of cell A1
COLUMNS finds the total number of columns of a given range, which is perfect for finding a column position within a table. The following formula will return number 7 which is the total number of columns of the table in my example, but please note it is NOT the relative column position of the last column to cell B3.
=COLUMNS(Tbl_WordRk)
You need to add -1 to the above formula to find the relative column number of the last column from B3. And therefore, adding -2 will return the relative column position of the second last column from B3.
So the final formula in cell B3 in my example is
=OFFSET(B3,,(COLUMNS(Tbl_WordRk)-2))-OFFSET(B3,,(COLUMNS(Tbl_WordRk)-1))
Then you just drag it down to the last row.
Just one more advice on the conditional format of your example, I would prefer not to show a green upward arrow if there is no change in the word ranking. If you know how to edit an existing conditional formatting, here is how to set it:
Cheers :)

Formula including a reference cell

Example: I need to count the number of values in a range that are greater than 3, but I don't want to have to rewrite the formula every time the criteria number may change. So the criteria number is calculated in a reference cell. So, lets say, 3 is entered in cell A2. A formula should be countif(C:C,>A2). Excel does not seem to like the greater than used with a reference cell. Is there a work around?
You need to use:
=COUNTIF(C:C,">"&A2)

Adding the sum of best 5 of 7 cells

So I have tried to use sumproduct to pull data from cells. My issue is that I would prefer to pick 5 individual cells vs a bank of cells.
I can make this formula below work, but it pulls "Place" cell values into the equation as well as "Points" value cells
Image of cells and formula
I would like to use the formula
=SUMPRODUCT(Large(C5,G5,K5,O5,S5,W5,AA5,{1,2,3,4,5))
to pull only from the 7 specific cells, but I get an error. as soon as I enter large, it only has the first 3 cells highlighted.
The error states that You've entered too many arguments for this function.
I am new to the Large formula as well, but it can only accept an array, not individual cells. You did specify individual cells which would lead to the next argument.
Since the Large formula only excepts 2 arguments you have too many and it fails with an error.
It is not a nice solution, but I guess the formula could work if you put your specific individual cells in neighbouring cells to create the array needed for the formula. (Or at least refer to them in some other cells to create the Array)
For the result you also would need 5 cells to enter the Sumproduct formula to display in each cell the 5 individual results.
Similar to:
=SUMPRODUCT(Large(A1:A7,1))
Where A1:A7 would be the newly created array where you reference:
in Cell A1 =C5
in Cell A2 = G5
in Cell A3 = K5
etc.
The LARGE function expects a single contiguous range as its first argument.
This array formula should circumvent that restriction.
=SUM(LARGE(IF(MOD(COLUMN(C:AA), 4)=3, C5:AA5), ROW($1:$5)))

Excel Formula Similar to Select-Case

I have five columns of data (A-E), most of which are blank. In column F, I want to display one value from the 5 cells in that row. Specifically, I want to display the rightmost cell with a value. For example, if A3 and D3 both have values, then it should populate with D3. If only B4 has a value, then I'd like that value. They all have formulas in them, but most of the formulas result in blanks.
I suspect this could be accomplished with nested IFs, but I'm hoping for a more concise way.
Use INDEX(MATCH())
=IFERROR(INDEX(A3:E3,MAX(IFERROR(MATCH(1E+99,A3:E3),0),IFERROR(MATCH("zzz",A3:E3),0))),"")
Since it is only 5 columns and if you have Office 365 Excel then you can use IFS():
=IFERROR(IFS(E3<>"",E3,D3<>"",D3,C3<>"",C3,B3<>"",B3,A3<>"",A3),"")
The first is more scale-able if other columns are added while the second is a little shorter with only 5 columns.

Conditional formatting for multiple rows (highlight lowest value in each)

I have a table in a sheet in Excel with over 2000 rows and about 500 columns of data (numbers). Values in a particular column header are being compared to each row underneath that header, and I am using a VBA function to calculate these values (in other words, I am comparing the value in B1 to the values in A2 through A2146, the value in C1 to the same range, etc). I want to highlight the lowest number in each row by filling the cell. I have researched this issue and tried to solve the problem by implementing this solution, but by using MIN instead of MAX:
=A1=MIN($A1:$TX1)
Columns A through TX contain data.
However, when I use this function as a formatting rule, Excel highlights the wrong values and sometimes multiple values in a row. For example, I have a row with a cell containing the value 10.2, which is the only cell highlighted in this row, even though it is neither the MIN nor MAX of the specified row. Additionally, I have another row which contains values 10.6, 8.4, 5.2, and 20.8. Each one of these values is highlighted based on the formatting rule above, though 5.2 is the obvious MIN; the other three cells with the aforementioned values, then, should not be formatted.
How can I remedy this? I have tried adjusting relative/absolute cell references to determine if this could be the problem, but I am quite sure that the way I'm referencing the cells is correct.
Courtesy #barry houdini (copied from a Comment):
Select the whole range of numbers B2:TX2146 (you can do that by typing that range in the box above A1 then press RETURN). Now set CF with the formula that applies to top left cell, i.e. =B2=MIN($B2:$TX2)

Resources