How to use arrayformula to indicate an occurrence in google sheets - excel

I'm trying to write an =arrayformula that finds the 1st, 2nd, 3rd, etc. occurrence of a value in another column. I can do this with a formula copied down all rows but I don't want to use this method, I need the arrayformula to simply always update the column because I need to constantly insert and delete rows and I don't want to have to keep copying the formula down. Thanks in advance.
Google sheet where I'm testing this.
Example formulas that I currently have to copy down..I want this to simply be an arrayformula instead:
values | occurance
aa | =if(A3<>"",countif($A$3:$A3,A3),"") | RESULT:1
2 | =if(A4<>"",countif($A$3:$A4,A4),"") | RESULT:1
aa | =if(A5<>"",countif($A$3:$A5,A5),"") | RESULT:2
5 | =if(A6<>"",countif($A$3:$A6,A6),"") | RESULT:1
5 | =if(A7<>"",countif($A$3:$A7,A7),"") | RESULT:2
4 | =if(A8<>"",countif($A$3:$A8,A8),"") | RESULT:1
Formulas that work but have to be copied down

Check out cell D3 where I used this formula:
=ArrayFormula(iferror(SORT(ROW(A3:A),SORT(ROW(A3:A),A3:A,1),1)-MATCH(A3:A,SORT(A3:A),0)-ROW()+2))
and see if that works for you ?

Related

How can I conditionally VLOOKUP in Excel?

Suppose I have the table I need to VLOOKUP() through:
id | indicator | value
-----------------------
1 | a | abc
1 | b | def
1 | c | ghi
2 | a | bbc
2 | b | bef
3 | a | aef
There is a table where I need to attach only values with indicator equal to a:
id | value
----------
1 | abc
2 | bbc
3 | aef
Something like conditional VLOOKUP() is required. What is the elegant way to do it?
You can do multiple criteria INDEX-MATCH to achieve this:
=INDEX($C$1:$C$6,MATCH($E1&"a",$A$1:$A$6&$B$1:$B$6,0))
This is array formula and it works by hitting Ctrl+Shift+Enter.
Also, I assumed that your Lookup value is in cell E1, which is something you can change according to your needs.
Use an array formula:
I found this formula in the web a few years ago, cant remember where, but credit to them.
=VLOOKUP(CONCATENATE(D2,"a"), CHOOSE({1,2},A$1:A$10 & B$1:B$10, C$1:C$10 ),2,0)
For this example I used column D on the same sheet for the reference ID and column E for the result. Amend the references as required.
Due to this being an array formula, every time the formula is entered you will need to select the formula bar and hold CTRL and Shift and press enter on the keyboard.

Generate List of Data from different sheets in excel

Here's the thing, I want to display a list of data from different sheets in excel file
Ex:
Sheet 1:
| A | B
--|---------------|--------------
1 | Payee: | Pedro
2 | Check Number: | 15263
3 | Date: | 12/05/2016
Sheet 2:
| A | B
--|---------------|--------------
1 | Payee: | Juan
2 | Check Number: | 15685
3 | Date: | 12/06/2016
and So on
Then in final sheet Display :
CheckNumber
15263
15685
I tried different formulas like VLOOKUP, INDIRECT, still I can't find answers.
Copy paste is not an option because I want it to be dynamic
Hope you guys Help
Assupmtions:
1. Name of the sheets of your workbook are Sheet1, Sheet2, Sheet3, and so on....
2. Check Number is always in Cell B2 of all sheets.
Enter the following formula in the second row of the column you want to list down Check Number and copy/drag it down(say Column B).
=INDIRECT("Sheet"&ROW()-1&"!"&"$B$2")
This will give you following output:
Actually i find a code here :https://msdn.microsoft.com/en-us/library/cc793964.aspx
i tried it and it works, though i use VBA because i cant find a formula for it

Excel: Select every 5th column on another sheet, drag and autofill

I'm looking to select every 5th column from another sheet, and put it into one row where they're next to each other, and be able to drag it so it autofills as there is a lot more columns.
It should come out like:
=Sheet1!B$4 | =Sheet1!G$4 | =Sheet1!L$4 | =Sheet1!Q$4 ...
=Sheet1!C$4 | =Sheet1!H$4 | =Sheet1!M$4 | =Sheet1!R$4 ...
...
How can I do this with a formula?
In your first cell of choice:
=INDEX(Sheet1!$4:$4,5*(COLUMNS($A:A)-1)+ROWS($1:2))
Copy across and down as required.
Note that INDEX set-ups should be preferred to volatile OFFSET/INDIRECT ones.
Regards

Increment count in column based on value in column

I've 2 columns A and B. A contains names and B contains the count of those names till that record as shown below.
-----------------------------------
| A | B |
-----------------------------------
1 | Fruits | 1 |
2 | Flowers | 1 |
3 | Fruits | 2 |
So, want to have a formula for this. Expecting an array formula. Even if an array formula is not possible, a general formula
Attached a spreadsheet so that it can be explained better.
https://docs.google.com/spreadsheets/d/1wlWqdFwgv90s50iP-bXXBHciyualohj610qFiSatcmQ/edit#gid=1997586177
You do not need an array formula, and I would avoid them when possible. You can accomplish your task with
=COUNTIF(A$1:A1,A1)
Where A1 if the first value in the column of values you want to count. The $ allows you to anchor the top of your COUNTIF range while leaving the bottom dynamic.
In a google spreadsheet you may want to try:
=ArrayFormula(iferror(SORT(ROW(A1:A),SORT(ROW(A1:A),A1:A,1),1)-MATCH(A1:A,SORT(A1:A),0)-ROW()+2))
Example sheet

Incrementing each row in excel that contains a number

I was sent an excel document in the following format:
A | B |
1 | abc |
| def |
2 | abc |
| def |
| ghi |
3 | abc |
| def |
So basically I have the first column which contains ordered numbers every couple of rows. I want to insert a row e.g. between 2 and 3, so that the new row will be numbered 3, and the rows below it are updated accordingly i.e. 3 becomes 4, 4 becomes 5 and so on.
I don't really use excel, but I am curious if there is there an easy way of doing this?
In A1, enter the following formula:
=IF(MOD(ROW(A1),2)=1,(ROW(A1)+1)/2,"")
And copy that formula down to the bottom of the range. Each time you insert a new row, you will need to manually copy the formula to the inserted row's first cell.
Is there a pattern in the b column, to distinguish if you need to jump to the next number?
if so use:
in cel A2 and further:
=IF(B2 = "abc",A1+1,A1)
With conditional formating, hide the repeating numbers: =A2=A1

Resources