What I have is a sheet with data and I want to define a non-contiguous range that can be used to, as an example, create a chart.
As long as the range is rectangular it's pretty easy defining the range.
range := ASheet.Range['A1', 'B10'];
This creates a rectangular range with the top left corner at A1 and bottom right corner in B10. The problem is when the data isn't defined so that it can be selected with a single rectangle.
As an example we have this data:
+-------+------+------+------+------+
| Time | Col1 | Col2 | Col3 | Col4 |
+-------+------+------+------+------+
| 01:20 | 5 | 1 | 101 | 51 |
| 01:21 | 6 | 1 | 101 | 51 |
| 01:22 | 5 | 0 | 101 | 51 |
| 01:23 | 5 | 0 | 101 | 51 |
| 01:24 | 5 | 0 | 101 | 55 |
| 01:25 | 5 | 1 | 101 | 55 |
| 01:26 | 6 | 1 | 101 | 15 |
| 01:27 | 7 | 2 | 101 | 15 |
| 01:28 | 7 | 2 | 101 | 15 |
+-------+------+------+------+------+
If I for example wish to create a chart for Time, Col1 and Col2 then the range is simply ASheet.Range['A1', 'C10']. If I want to create the chart for Time, Col1, Col3 and Col4 it's not possible to create a range this way (since Col2 shouldn't be included).
In VBA it's possible to create the desired range by simply .Range("A1:B10,D1:E10"). Unfortunately there doesn't seem to be an equivalent way of defining a range in Delphi (Excel2010), in fact it seems to only support range with the format .Range[topLeft, bottomRight].
My question is: How do I define a non-contiguous range in Delphi?
After hours and hours of googling I stumbled upon the key part: Application.Union, when reading through the documentation for Range object for the nth time.
The solution is to use the Excel object method Union to make a union of two contiguous ranges in order to define a new range, which can be non-contiguous.
Example:
ExcelApp := TExcelApplication.Create(..);
...
Range1 := Sheet.Range['A1', 'B10'];
Range2 := Sheet.Range['D1', 'E10'];
Range := ExcelApp.Union(Range1, Range2);
Related
I have two columns, A and B, where A contains the number of values for corresponding value in B. I want to create column C that contains the number of values from A but with the value from B. So for example:
| A | | B |
| 2 | | 40 |
| 3 | | 60 |
Should produce:
| C |
| 40 |
| 40 |
| 60 |
| 60 |
| 60 |
So 2 of 40 and 3 of 60. This could be in memory (I only want to use C in a formula, don't really need it as an actual column) or as its own column.
Give a try on below formula-
=ArrayFormula(TRANSPOSE(SPLIT(TEXTJOIN("#",TRUE,REPT(B1:B2&"#",A1:A2)),"#")))
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))
I would like to get the SUM of the values of comma separated variables (Issued Items) in Google Sheet. Please see the table below;
+-----------------------+-----------+
| Issued Items | SUM |
+-----------------------+-----------+
| A-22, A-22, B-11 | 120 |
+-----------------------+-----------+
| C-33, 11, 22-X | 160 |
+-----------------------+-----------+
| 22-X, D-54, 22 | 110 |
+-----------------------+-----------+
Edited: The Values for each Item will be stored in another sheet. And how can I get the count of Issued items?
Please note that the Items may repeat in a single cell and may also have prefix and suffix which are needed to be counted as individuals.
+-----------------------+-------+
| Items | Values | QTY |
+-----------------------+-------+
| A-22 | 50 | 2 |
+-----------------------+-------+
| B-11 | 20 | 1 |
+-----------------------+-------+
| C-33 | 70 | 1 |
+-----------------------+-------+
| D-54 | 40 | 1 |
+-----------------------+-------+
| 11 | 30 | 1 |
+-----------------------+-------+
| 22 | 10 | 1 |
+-----------------------+-------+
| 22-X | 60 | 2 |
+-----------------------+-------+
It would save a lot of time and effort for me.
Please help and thanks in advance.
=SUM(ARRAYFORMULA(IFERROR(VLOOKUP(TRANSPOSE(SPLIT(D2, ", ")), A:B, 2, 0))))
={"QTY"; ARRAYFORMULA(IFERROR(VLOOKUP(TO_TEXT(A2:A),
QUERY(TRANSPOSE(SPLIT(TEXTJOIN(", ", 1, D2:D), ", ")),
"select Col1,count(Col1) group by Col1 label count(Col1)''", 0), 2, 0)))}
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.
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.