How do I count merged cells separately in Google Spreadsheets? - google-sheets

I'm using countif(a1:a10, "*") to sum the number of names in a guest list. However, some cells have been merged, e.g. for married couples or families where only one name is supplied.
See below for a concrete example, where (+ x) are merged with the cell above:
| A | B |
1 | Cheah | Teo |
2 | Hadi's Family | Robinson |
3 | (+ wife) | Müller |
4 | (+ son) | Chan |
5 | Ganesan | Yeong |
6 | Chng | (+ wife) |
7 | Tan | Ng |
8 | Williams | (+ husband) |
9 | Brecht | (+ daughter) |
10 | Ahmad | |
In the example above, I would like to obtain 10 in column A and 9 in column B.
I've seen #MaxMakhrov's suggestion of last non-empty row, but haven't been able to get a working solution out of it yet.
Any ideas?

The formula of finding last non-empty row may help:
=MAX(FILTER(ROW(A:A),A:A<>""))
But it will give the wrong result if last cells are merged:
Example:
1 a
2
3 b > merged
4
Last non-emty row is 2 in example above because cells 2,3,4 are merged.

Related

LOOKUP always selects the last number in the column

I Have a list of 40 numbers similar to below
+-----------+------------+
| J | T |
+-----------+------------+
| 1 | 123.4 |
+-----------+------------+
| 2 | 223.8 |
+-----------+------------+
| 3 | 23.4 |
+-----------+------------+
| 4 | 443.9 |
+-----------+------------+
| 5 | 143.5 |
+-----------+------------+
So I want to look up a number in the first column based on the second.
So I am using the following formula (actual sheet has 40 numbers) =LOOKUP(23.4,$T$43:$T$82,$J$43:$J$82) in this example I would have expected the result to 3 but it is always 5 (40 in the actual sheet).
Where am I going wrong?
let use VLOOKUP() instead
=VLOOKUP(23.4,{$T$43:$T$82,$J$43:$J$82},2,FALSE)
because LOOKUP() doesn't have the option or the argument for exact match
I hope it'll work for you
Or use Index/match:
=index($J$43:$J$82,match(23.4,$T$43:$T$82,0))

How to copy a whole row as a template and replace one columns value in Google Sheets

I have a sheet which im using to build product data. I need to handle some custom SKU's and id like to have them stored in a string like "XYZ,ABC,FGH" in an alternate sheet.
The generic products are generated in the other sheet for various sizes automatically. I would like on the end of this list to be able to take one of these automatic rows as a template and replace the SKU with one of the custom SKU's if they exist in the other config sheet.
So for example:
SKU'S | Name | Width | Height | Weight | Quantity
--------------------------------------------------
PARENT| X | 10 | 20 | 100 | 0
M1 | X | 10 | 20 | 100 | 1
M2 | X | 10 | 20 | 100 | 2
M3 | X | 10 | 20 | 100 | 3
M4 | X | 10 | 20 | 100 | 4
M5 | X | 10 | 20 | 100 | 5
Then append:
ABC | X
XYZ | X
FGH | X
Keeping the existing columns the other products use.
The X's are just a representation for the other columns I want to copy (ive added some further columns as example data). The only thing I want to change is the SKU. Its a duplicate apart from the SKU (which I want to replace) and the Quantity. The consistent one to copy and use as the template would be the row with PARENT as the SKU.
The result is to just be a new row underneath M5 row. These are additional rows to just be tagged onto the end except for a change in the SKU.
The import is a lot of duplication to the database which is the product attributes like width, height, depth, weight, etc. This is set in a sheet I made with the name VARS. So I would create a simple field in VARS for 'Custom Additional SKUs' in say VARS!$B$10 with the value 'ABC,XYZ,FGH'. These would then use the same columns as the SKU's in say a sheet called INVENTORY.
The end result would be something like:
SKU'S | Name | Width | Height | Weight | Quantity
--------------------------------------------------
PARENT| X | 10 | 20 | 100 | 0
M1 | X | 10 | 20 | 100 | 1
M2 | X | 10 | 20 | 100 | 2
M3 | X | 10 | 20 | 100 | 3
M4 | X | 10 | 20 | 100 | 4
M5 | X | 10 | 20 | 100 | 5
ABC | X | 10 | 20 | 100 | 0
XYZ | X | 10 | 20 | 100 | 0
FGH | X | 10 | 20 | 100 | 0
Final solution based on feedback to help others.
Based on the great input from pnuts I went with the following in column A underneath:
=sort(transpose(split(VARS!A1,",")),1,TRUE)
In column B:
=IF(ISBLANK(A7),"",QUERY(SKU!A2:F2,"select B,C,D,E,F",0))
Works like a charm!
Maybe try:
=sort(transpose(split(NamedRange1,",")),1,TRUE)
and next to the above something like:
=QUERY(SKU!A:F,"select B,C,D,E,F where A='PARENT'",0)
copied down to suit.

Matching cell and returning average of multiple columns

I have a Google Sheets with the following sheets:
Heroes
A | B | C | D | E
-------------------------------------------------------
The Flash | 5 | 10 | 4 | 82
Jesse Quick | 0 | 2 | 5 | 4
Quicksilver | 1 | 3 | 12 | 2
Kid Flash | 10 | 9 | 7 | 17
Calc
A | B
-------------------------------------------------------
The Flash |
Quicksilver |
I want to match column A in Calc and return the average value of column B to E from Heroes.
So based on the date above, I want Calc should look like this:
A | B
-------------------------------------------------------
The Flash | 25,25
Quicksilver | 4,5
I had this function in Calc:
=AVERAGEIF(Heroes!A:A;B2;Heroes!B:B))
changed to:
=AVERAGEIF(Heroes!A:A;B2;Heroes!B:E))
but this only returns 5 for The Flash and 1 for Quicksilver.
You can try this
=AVERAGE(ARRAYFORMULA( VLOOKUP(A5,A12:E13,{2,3,4,5},FALSE)))
Where A12:A13 refers to HEROES
and A5 refers to Cal
https://docs.google.com/spreadsheets/d/1AEbci4BN8SyYcmpfOELGRQC4wpRqPn-dUoZy5GdkTyM/edit?usp=sharing
For the Flash have: =AVERAGE(Heroes!B1:E1)
For Quicksilver have: =AVERAGE(Heroes!B2:E2)
Using this pattern allows you to get the average of all the Cells in the column of the hero you want. Remember you have to specify the cells, right now you are specifying the whole columns of B-E, when you just want the row of each hero.

How to add the content of a certain number of rows just below the VLookup output (Google spreadsheet)?

For instance:
________A_____|__B__|__C__|
1 | Mouse | 1 | a |
2 | Keyboard | 2 | e |
3 | Headset | 3 | i |
4 | HDD | 4 | o |
=Arrayformula(VLOOKUP("Mouse",A1:C4,{2,3},FALSE) --would return "1" & "a".
Is there a way to make it return the content of 1 row below as well, that "2" & "e" along with "1" & "a"? i.e., the desired final output should look like :
________C_____|__D__|__E__|
1 | | 1 | a |
2 | | 2 | e |
Thanx!
Try offset:
=OFFSET(A1,MATCH("Mouse",A:A,0)-1,1,2,2)
Offset in Google sheets is an arrayformula, so it can return multiple rows and columns.
Match function gives the number of row with matched name.

Coloring cells based on numbers in string

In my sheet, on column A I have a string of numbers divided by commas. Then there are 12 numbered columns, each with its own hour. How can I shade the cells if their column's number is listed in column A?
Here is an example of what I am hoping to achieve.
| A | B | C | D | E
1 | | 1 | 2 | 3 | 4
2 | 1,2,4 | (shaded) | (shaded) | | (shaded)
3 | 2,3 | | (shaded) | (shaded) |
Select the whole range
Apply conditional fofmatting
select custom formula: =MATCH(B$1,SPLIT($A2,","),0)>0

Resources