VB Script- read excel column values and assign it a dynamic array and form different sets of combinations of data - excel

I have a requirement to form a permutation data from the given set of values in excel sheet. Below are the details.
Let us say there are 5 columns and each column has some rows of data as below in input excel sheet.
Column 1 - 2 values(ind,us)
column 2 -1 value (a1)
Column 3= 3 value(cat,dog,cow)
column 4= 4 value(1,2,3,4)
Column 5= 1 value(d)
The output excel has to be on below format.
ind,a1,cat,1,d
ind,a1,cat,2,d
ind,a1,cat,3,d
ind,a1,cat,4,d
ind,a1,dog,1,d
ind,a1,dog,2,d
ind,a1,dog,3,d
ind,a1,dog,4,d
ind,a1,cow,1,d
ind,a1,cow,2,d
ind,a1,cow,3,d
ind,a1,cow,4,d
us,a1,cat,1,d
us,a1,cat,2,d
us,a1,cat,3,d
us,a1,cat,4,d
us,a1,dog,1,d
us,a1,dog,2,d
us,a1,dog,3,d
us,a1,dog,4,d
us,a1,cow,1,d
us,a1,cow,2,d
us,a1,cow,3,d
us,a1,cow,4,d
please note the rows and column count are not constant.
Request all to give some thoughts to implement.
Thanks,
Rakesh

See this question for ways to get (all) combinations of elements with specified values for each slot. Just feed your data as an array of arrays to the Permute function or the .init method.

Related

Excel - Lookup date in matrix and return column heading

I have a matrix between Products and Enablers, where the intersection between the two represents a point in time.
Product list
Enabler 1
Enabler 2
Enabler 3
Product 1
10-Oct
11-Oct
20-Oct
Product 2
20-Nov
25-Nov
01-Dec
Product 3
10-Oct
21-Oct
25-Oct
I need to turn this into a 'timeline' view so visually there are two ways to see the data, where the dates are across the top and based on the timing in the first table, it returns the corresponding 'Enabler' at the correct date...something like
Product list
10-Oct
11-Oct
12-Oct
Product 1
Enabler 1
Enabler 2
Product 2
Product 3
Enabler 1
Does anyone have any ideas how I'd do this? I think it requires an INDEX MATCH array formula as it needs to look across the matrix to find the date in that row, then return what is in the header column...but this isn't my area of expertise and I just can't seem to figure out how to make it work.
One approach might be to return this as an array. You could do:
=IF( ( Table1[[Enabler 1]:[Enabler 3]] = B7:D7 ) * ( Table1[Product list] = A8:A10),
Table1[[#Headers],[Enabler 1]:[Enabler 3]],
"" )
where Table1 is an Excel Table that holds your Product List and Enablers as columns (as shown in your first table); A8:A10 is the list of products in your second table; and B7:D7 is the list of dates in your second table shown as column headers. The formula would be placed in the upper left cell of your second table - in my example, B8 as shown here:
The result will spill into the second table.
If you wanted your second table to be an Excel Table, the approach
would be different as arrays cannot spill into Excel Tables.

Indexing Groups of Data

I have 10,000+ row of values which need to be indexed with a numerical value which increases by 1 every 56 rows - for example:
Rows Index Value
1-56 1
57-112 2
113-168 3
169-224 4
Any ideas?
Thanks! :-)
If your data starts in Row #2 like your example implies, then try this formula in Row #2 the column where you want your "index number":
=INT((ROW()-1)/56)+1
The 1 in the middle is "how many rows to skip at the top", and the 56 is obviously the size of each group.
More Information:
Office Support : ROW Function (Excel)
Office Support : INT Function (Excel)

Find the top n values in a range while keeping the sum of values in another range under x value

I'd like to accomplish the following task. There are three columns of data. Column A represents price, where the sum needs to be kept under $100,000. Column B represents a value. Column C represents a name tied to columns A & B.
Out of >100 rows of data, I need to find the highest 8 values in column B while keeping the sum of the prices in column A under $100,000. And then return the 8 names from column C.
Can this be accomplished?
EDIT:
I attempted the Solver solution w/ no luck. 200 rows looks to be the max w/ Solver, and that is what I'm using now. Here are the steps I've taken:
Create a column called rank RANK(B2,$B$2:$B$200) (used column D -- what is the purpose of this?)
Create a column called flag just put in zeroes (used column E)
Create 3 total cells total_price (=SUM(A2:A200)), total_value (=SUM(B2:B200)) and total_flag (=(E2:E200))
Use solver to minimize total_value (shouldn't this be maximize??)
Add constraints -Total_price<=100000 -Total_flag=8 -Flag cells are binary
Using Simplex LP, it simply changes the flags for the first 8 values. However, the total price for the first 8 values is >$100,000 ($140k). I've tried changing some options in the Solver Parameters as well as using different solving methods to no avail. I'd like to post an image of the parameter settings, but don't have enough "reputation".
EDIT #2:
The first 5 rows looks like this, price goes down to ~$6k at the bottom of the table.
Price Value Name Rank Flag
$22,538 42.81905675 Blow, Joe 1 0
$22,427 37.36240932 Doe, Jane 2 0
$17,158 34.12127693 Hall, Cliff 3 0
$16,625 33.97654031 Povich, John 4 0
$15,631 33.58212402 Cow, Holy 5 0
I'll give you the solver solution as a starting point. It involves the creation of some extra columns and total cells. Note solver is limited in the amount of cells it can handle but will work with 100 anyway.
Create a column called rank RANK(B2,$B$2:$B$100)
Create a column called flag just put in zeroes
Create 3 total cells total_price, total_value and total_flag
Use solver to minimize total_value
Add constraints
-Total_price<=100000
-Total_flag=8
-Flag cells are binary
This will flag the rows you want and you can grab the names however you want.

Pivot chart count number of serial samples not repeated samples

I have an excel database that consist of ID, Name and Sample Date. I made a pivot table to count the number of names and samples each name has but I want a count of the number of serial samples each name has, not including repeated samples.
Here is an example database:
ID Name Sample Date
M1.1 A 8/2/2013
M2.1a B 8/6/2013
M2.1b B 8/6/2013
M2.1c A 8/6/2013
M1.2 A 8/7/2013
M3.1 C 8/9/2013
M4.1 D 8/10/2013
M1.3 A 8/11/2013
M2.2 B 8/13/2013
I want the pivot table to be able to count that A has 4 serial samples, B has 2 serial samples instead of 3, C has 1, and D has 1.
Any suggestions on how to do this?
Not elegant but for want of any other answer so far:
Add a helper column containing =COUNTIFS(B:B,B2,C:C,C2) and copy down to suit. Order on that helper column and restrict the PivotTable range to include only half of those entries that show up as duplicates.

Excel sort data in newspaper style columns

I have an excel sheet that has names and extension numbers. The sheet is designed to be printed as a reference and so it has the data split into 3 columns like how a newspaper is laid out.
EXT Name EXT Name EXT Name
1 bob 4 pete 8 sam
2 dave 5 sally 9 john
I need to have excel sort this data on name, A-Z. I can only work out how to make it sort one column at a time and so I end up having to manaually sort the data every time I add or remove information.
Can excel sort all 3 columns top to bottom and left to right?
Thanks!
Maybe this KB artikel helps.
Or u can try using the small function like
Column A
=SMALL($A$1:$A$9;0+ROWS(A$1:A1))
Column C
=SMALL($A$1:$A$9;30+ROWS(A$1:A1))
In this case you clone the sorted dataset, which is in two columns
The value for the B colums can be found using a vlookup. the value 0 and zero are an offset, so the length of the page is fixed

Resources