How to assign sequence number when the value entered into nearby cell? - excel

I want A column to automatically generate sequence number when B column has value inserted.
As my image shows(assign sequence number.jpg), when firstly insert a in B1, it will generate 1 as first insert in A1.
When insert next value b in B5, generate 2 as 2nd insert in A5.
Please help.
I tried IF(B2<>"",MAX($A$1:$A$10)+1,"") but it didn't work.
assign sequence number.jpg

The below mentioned formula will work. But the only thing here is you have to enter 1 in cell A1. Then enter the below formula in A2.
=IF(B1:B10="","",COUNTIF($A$1:A1,">0")+1)
You can change the range according to your requirement. Let me know if this works.

Related

filling excel column automatically where another column is not null

I want to fill an excel column with a specific value where another column in the same sheet is not null(I've used '-' for all the empty cells). Can I automate this?
For example, in the screenshot, where ever I have a value, I want to insert 'Hi' (Only at the places with a value) and omit where there is blank space represented by '-'. Also, it should not edit the values in B column if there is anything already present in it.
You can use if function to do this task. Suppose you have data to test in Cell A1 then you can enter Formula in cell B1 as =if(A1<>"-","Hi","") this means if Data in cell A1 is not - then enter Hi in cell B1 else keep B1 empty. See Screenshot attached.
You can do the following: suppose column A is full of values and you want to fill column B with "-". First, write the value "-" in the cell "C1", then select column B and write in B1 =$C$1 and then press Ctrl+Enter Key that's it
=IFERROR(IF(B1="","-",COUNTBLANK(INDIRECT("B1:B"&ROW()-1))+1),1)
Or avoiding INDIRECT:
=IFERROR(IF(B1="","-",SUM(IF(INDEX(B:B,SEQUENCE(ROW()-1))="",1))+1),1)

Capture adjacent Cell with condition Ask Question

Capture adjacent Cell with condition
I have values in A column and corresponding values in B column. I need to capture based on A column value I need to capture adjacent cell value which has no zeros.
Say we have data like:
and we want to retrieve a value from column B that corresponds to alpha in column A, but which is not 0. We can use an array formula with MATCH()to achieve this:
First place:
alpha
in cell D1 and in E1 enter the array formula:
=INDEX(B:B,MATCH(1,(A:A=$D$1)*(B:B<>0),0),1)
Array formulas must be entered with Ctrl + Shift + Enter rather than just the Enter key. If this is done correctly, the formula will appear with curly braces around it in the Formula Bar.

Excel Formula to find the first higher value

In column D (Result), I would like to have the following formula.
For each Cell in column C, find in column B the first value higher than the value of the cell of column C (starting from the same row) and gives as output the difference between the values found in column A (Count).
Example:
the value in C2 is 40. the first cell of B that has a value higher than 40 is B6. So D2 takes A6.value - A2.value = 5 - 1 = 4.
Can it be done without the use of VBA?
It can easily be accomplished with an array formula (so you have to enter the formula with Ctrl+Shift+Enter ) :
{=MATCH(TRUE;IF(B2:$B$7>C2;TRUE;FALSE);0)-1}
Put this formula in cell D2, and just drag down. You only have to change the end of your data set (change $B$7 into the real last cell of the column with data)
The formula works as follows :
The IF statement results in an array with TRUE/FALSE values that meet your criteria : {FALSE;FALSE;FALSE;FALSE;TRUE;FALSE}
The MATCH (with the 0 switch) searches the array for the index of the first match, which is 5 in our case
And you have to subtract 1 to get the offset to the cell where the function is placed, so this gives you 4
So although you have to enter it as an array formula (you will get an N/A error without the ctrl+shift+enter), the result is just a single number.
Also, depending on your data set, you might want to add some ERROR handling in case no match has been found, e.g. just using the example data set in your question, the result in cell D5 will be N/A so you have to decide what value you want the result to be in such case.
And finally, I did not use the values in column A, as I assumed this is just a sequential ascending counter. If this is not the case, and you specifically want to find the difference between the corresponding values in that column, you can use the variant mentioned by Foxfire... in one of the other answers: =MIN(IF(B2:$B$6>C2;A2:$A$6))-A2
A slightly adjusted and shortened answer on Peter K.'s suggestion:
In D2:
=MATCH(TRUE,$B3:B$7>C2,0)
enter the formula with ctrl+shift+enter
Something like this should work for you. First transform your range to a table.
=IFERROR(AGGREGATE(15,6,--([#Second]<[First])*(ROW([#Second])<=ROW([First]))/--([#Second]<[First]*(ROW([#Second])<=ROW([First])))*[Count],1) - [#Count],"")
In this formula the comparison between [second] and [First] starts at the same row. That means that the value in D5 is 0 and not 1. (Like #Foxfire And Burns And Burnslike stated in the comments).
Ok, I did not post the answer waiting until OP answered why D5 is 1 instead of 0, but my formula is also an array formula. It would be:
=MIN(IF(B2:$B$6>C2;A2:$A$6))-A2
To type this formula in array mode, you need to type it as usual, but instead of pressing ENTER, you need to press CTRL+SHIFT+ENTER

How to update row value automatically in excel

How can I update the row values automatically in cell ?
Please see below image
If I change the value of "1" to "12" I want the down arrow cells to follow from it but increment by 1 like the image below
Write formula - =1 + A1 and drag it down to your limits.
change value 1 to any value, it will follow the increment as you want.
Assuming that the value 1 in your first image is cell A1, then yo7 can enter the followint formula into A2:
=A1 + 1
Then, copy this formula down the A column as far as you need. Now when you change the value of A1 to some other value, the whole column should update.

Sequence number in excel for non blank rows

How to add sequence numbers in excel, wherein the sequence number starts based on the value of the column B. It should not add the sequence if there is no text in the corresponding row of Column B.
So the row 4 should start with 1 since the column B is having some value.
The example sheet is attached.
Also how can i auto update the sequence if i add new row to it.
In A2, enter the following formula and copy down as required.
=IF(B2="","",MAX($A$1:A1)+1)
In A2
=COUNTA(B$2:B2)
and fill down

Resources