How To Filter Multidimensional Array Based On Conditions

Jul 18, 2014

How to apply a filter over the array "a" shown below and get the result in a new array "b" containing the filtered values based on the following conditions (the conditions criteria could be 1, 2 or 3. In this case only 2):

Criteria1 in Column 4="yellow"
Criteria2 in Column 3="ggg"

And only show values of columns 1 and 3.

If were using an SQL query would be something like this:

Code:
SELECT F[1],F[3] FROM "Table" WHERE F[4]="yellow" and F[3]="ggg"
The output array would be as below:

Code:
b=[{12,"ggg";140,ggg}]
this is the array:

Code:
Sub test()

a = [{"122","53","ggg","yellow";"140","9","ggg","yellow";"16","-22","ddc","yellow";"127","-37","ddc","green";"53","-28","ggg","grey"}]

'Filter code to get array b
'
'
End Sub

View 1 Replies


ADVERTISEMENT

Creating Multidimensional Array?

Feb 27, 2013

I want to create a multidimensional array. Basically, I want to tie a file to a sheet. I want to import the following files:

"byemployee.csv",
"byposition.csv",
"Status report.xls",
"bydepartment.csv",
"byband.csv"

to the following sheets in my workbook:

"byEmployee",
"byPosition",
"statusReport",
"byDepartment",
"byBand"

Basically, I would like to pass the array by reference. Basically, the code below imports the file into my workbook, but I since I have several files going into sheets in the workbook, I don't want to write the code 5 times. I figured the best way would be to create a multidimensional array and pass through my procedure below.

Code:
Sub import_Employee_Data()
strSourceFile = ThisWorkbook.Name
strPath = ThisWorkbook.Path & ""
strFirstImportFile = strPath & "byemployee.csv"
sDestSheet = "byEmployee"
If Len(Dir(strFirstImportFile)) > 0 Then

[code]......

View 8 Replies View Related

Sorting A Multidimensional Array

Feb 28, 2007

I’m working on a project where a spreadsheet holds data which is spread over multiple rows. The number of rows can change depending on the case.

Imagine 1 case being 1 row of certain details, then a various number of rows below detailing some different information in different columns.

A crude example is this: ...

View 9 Replies View Related

Returning A Multidimensional Array

Mar 9, 2007

I'm getting a compile error "Can't Assign to array" when I try to return a multidimensional array from a function. I'm not a VB expert, and I was unable to find any examples of returning a multidimensional array from a function. Here is some sample

Sub someSub
Dim data(1 To 4, 0 To 23) As Integer

For counter = 1 To numSheets
data = processData(counter, data) ' The error happens here
Next
End Sub
Private Function processData(counter As Integer, data() As Integer) As Integer()
Dim dataCopy(1 To 4, 0 To 23) As Integer

dataCopy = data
'modify dataCopy
processData = dataCopy
End Function

View 6 Replies View Related

Print Every Element In Multidimensional Array

Mar 19, 2014

I have 9 named ranges on worksheet Sheet1. I want to print every combination of every non-singular range on worksheet Sheet2. Below is a simplified version of the scenario.

There are three named ranges: Letters, Colors, Animals. Say the below are the entries for each range.

Letters = {A, B, C}
Colors = {Red, Blue}
Animals = {Dog}I want to print every combination of Letters and Colors but exclude Animals since it only has 1 entry.

Therefore my result would look something like this:

A Red
B Red
C Red
A Blue
B Blue
C Blue

My thought is to make a multidimensional array GrandArray where GrandArray(1) = Letters and GrandArray(2) = Colors, then recursively go back through every combination and print to Sheet 2. I can set up GrandArray, but stepping through each element is creating mismatch errors.

I'm trying to avoid For loops since my real data has 9 ranges which may or may not be included in the final print.

View 1 Replies View Related

Passing Multidimensional Array To Function

Jul 15, 2014

I'm trying to pass a multidimensional array to a function that I have defined, but I receive an error about an object mismatch. Here is what I have in regards to the array and function. What should I change?

Code:
Dim diffArray() As Integer
Dim countArray() As Integer
Redim countArray(count,2)

diffArray = getRunningSum(countArray)
End Sub

Public Function getRunningSum(ByRef countArray() As Integer) As Integer()
'Code here......
End Function

View 9 Replies View Related

Dictionary Object And Multidimensional Array

Dec 31, 2008

I have data in a dictionary object and need to load it into a two column listbox. The VBA help says you can load data into a multicolumn listbox from a 2D array. So my question is how can I extract the data from a dictionary object directly into a 2D array.

The dictionary object stores data in key and item pairs. So the 2D array would have one dimension for the keys and the other for the items. I want to do this without having to extract the items and keys into separate 1D arrays and then loop through them to build the 2D array.

View 9 Replies View Related

Calculate Each Element In A Multidimensional Array

Jul 28, 2006

I need to multiply matrix variable by a constant (each matrix entry has to be multiplied by the constant).

Sub Matrix()
Dim X As Variant, Y As Variant
Dim a As Integer

a = 2
X = [1, 1, 1; 2, 2, 2; 3, 3, 3]

Y = X * a ' Here it writes that type is mismached

End Sub

I read that in cell functions it is possible to do such calculations.

View 4 Replies View Related

Dump Contents Of Multidimensional Array To Worksheet

Jan 23, 2009

Rather than looping through a multidimensional array to populate a worksheet, is there a quick function which can export the entire array to a worksheet?

View 2 Replies View Related

Slicing Array Based On Conditions

Oct 19, 2011

Given an input array (result of a calculation )

Input Array = [3 4 9 1 0 5 7 2 0 6 10 8 ]

Depending on the number and location of the zeroes, I would like to create a sorted array whose

- number of rows is determined by the number of zeroes in the input matrix (i.e number of zeroes - 1)

- number of columns determined by the the size of one maximum number of elements in one of the smaller arrays. The remaining entries on the other shorter rows will be made zero.

For the above example sorted array becomes a 3X4 array

1 3 4 9
2 5 7 0
6 8 10 0

Example 2

Input Array = [9 4 5 0 1 7 6 2 10 3 8]
Sorted Array is a 2X7 Array
4 5 9
1 2 3 6 7 8 10

I would like to generate this array in VBA (rather than writing/reading in a worksheet) as it will save a lot of calculation time.

View 3 Replies View Related

VBA - Collecting Array Of Sheets Based On Conditions

May 11, 2011

I need a code to select sheets with pages less than 15 to print out. Also, a code to print out just the first 5 and last 5 pages if its more than 15 pages.

I've tried this so far but no success:

For X = 1 To Worksheets.Count

If Y Is Nothing Then
Set Y = Sheets(X)
Else
If ExecuteExcel4Macro("Get.Document(50)") < 10 Then
Set Y = Union(Y, Sheets(X))

End If
End If

Next X
Y.Select

View 6 Replies View Related

Filter An Array (the Longer One) Using The Shorter Array As The Criteria

Aug 26, 2009

I am trying to filter an array (the longer one) using the shorter array as the criteria. I am currently doing this using the following method

IF(LOOKUP(lookup cell, array)=lookupcell, lookupcell, "FALSE")

I then copy and paste 'values' and filter out the 'false' to get my final result.

This has worked in the past, but for some reason that I simply can't figure out, the formula isnt working! I've attached the example, and I've highlighted a number in blue (cell E522 and C103), (that should be being found in the 'LOOKUP' function) but is returning a "FALSE". I have looked over the code and simply can't figure out why Excel isn't returning the right value.

This is obviously happening for a quite a few of my numbers, as my filter result is returning an array that is about 1500 shorter than it should be. I have highlighted E522 as the 'example cell' to look at.

View 6 Replies View Related

Advanced Filter With AND + OR Conditions

Nov 17, 2007

I am trying to create my critera section for an Advanced Filter, but it seems like Auto Filter uses each row as a specific filter.

i.e. If I need to filter all the "2"s in column A, but both the "1"s and "2"s in column B, I need to create two different filters like this:

Column A Column B
2 1
2 2

Instead of just:

Column A Column B
2 1
2

Is there any way I can use auto-filter without having to put in every possible combination of my criteria in as different filters? Auto Merged Post;I did try creating columns next to each other, but that seems to only work as an "AND."

Per my example, I need to return everything with column A = 2, and column B = 1 or 2.

Except in my actual spreadsheet, it's more like where A = {1,2,3,4,5} and B = {0,9,8,7,6} and C = {a,b,c,d,e}

View 7 Replies View Related

Filter Data For Viewing Using Multiple Conditions

Jun 16, 2009

I am far from advanced in excel, but I have been tasked with creating a macro which includes filtering.

1) I have a workbook called Workbook1
2) I need to copy Sheet 3 from Workbook1 cells A1-J5000 into a new workbook called Master.
3) Column D is labelled Status and the two statuses are Enabled and Disabled.
4) I need to copy anything labelled Enabled to a new worksheet in the workbook already created called Enabled and then the same for Disabled. I then need to put it into date order which is column F labelled Date.

I have been trying to work on this all morning, but have found that Excel doesn't like Macros with filters and I don't know the first thing about VBA

View 4 Replies View Related

Array SUM Formula With Range Of Conditions

May 14, 2014

1) Input data are static and helper columns can be added if needed.

2) Filter will be dynamic range (in attachement is the filter static), and the count of years can be changed on users request. So there could be only 2011, but also 2011+2012, 2012+2013+2014 etc.

3) In col 'J', the is what I know to do, but I do not want to use SUMIF+SUMIF+SUMIF... for each year (the count of years will change througt time as mentioned above).

View 3 Replies View Related

Sum Range Of Data From Array Of Conditions

Mar 15, 2014

I am trying to pick certain data from a table and sum it in order to produce a formatted report.

The data has many different items of which I want to pick certain ones to sum on one line

See attached and some of the formula's that I have used, but aren't quite what I'm after

The formula I want to use is .... VLOOKUP(E5:G5,A14:C23,3,) ......

But it wont reference a range (E5:G5) !!! and I also want the formula to ignore blanks (as blanks in the data file are actual totals).

View 2 Replies View Related

Array Formula To Evaluate Two Conditions

Jan 16, 2010

I have a spreadsheet that contains two worksheets called: MasterApplication and LocalAdmin. The Local Admin worksheet as shown below contains the following information starting on row A1:D456 ....

View 9 Replies View Related

Array Formula: Add Data Which Meets Certain Conditions

Jan 1, 2009

I'm working with wookbooks used company wide and I cannot add any helper columns which would solve the problem. I need to add data which meets certain conditions see attached workbook for a sample.

View 5 Replies View Related

SUMIF Or An Array Formula - Matching Multiple Conditions

Jan 14, 2009

I would like to have a formula in one cell that finds records on another sheet that meet certain criteria, and produces a sum of the total quantities associated with that record. The attached workbook has more details as to what I am trying to do.

View 2 Replies View Related

Summing Values From Array W/ Multiple Conditions-cols

Oct 1, 2007

I know there have been many posts about multiple conditions in arrays, but I didn't find one that applied to my situation, so I'm hoping can help me out of jam. I'm using Excel 2000 on XP.

I have a database of sales information. Customer name is listed in column C, and columns F through Q contain the sales for the months of July - June (fiscal calendar year), with the headers for the months in row 4. There can be many rows of sales for the same customer, hence the need to sum them.

Example

C F G H
CUSTOMER JULY AUGUST SEPTEMBER
customer1 2 3 4
customer1 2 3 4
customer2 2 3 4
customer2 2 3 4

The problem is that this information will need to be updated every month to reflect sales year-to-date, meaning that the conditions for summing the data will change depending on how far into the year we are. So for instance, in August I will need to sum all the records for customer1 in the July column (column F) and the August column (column G), but next month it will have to sum the records for customer1 from July, August, and September (col H).

The result of this information would be displayed on a different worksheet. My thought was to assign a range of 12 cells (Sheet2!A1:A12) and to populate those cells with any of the months that need to be summed thus far. So for example, through September, A1 = "July", A2 = "August", and A3 = "September". Then the formula would use those values to evaulate the conditions. So in plain English the formula would:

sum the values in columns F : Q where the monthly header = the values in the range Sheet2!A1:A12 for all records where CUSTOMER = CustomerName

View 9 Replies View Related

Array Formula- Idenify The Location Of Each Row In Which All The Conditions Are True

Nov 9, 2007

My formula below work perfectly. I was wondering if their is a way for me to idenify the location of each row in which all the conditions are true. So, for example, if the formula generates an answer of 2, in a different cell it would give me the address of the 2 rows.

=SUM((K9:K72/L93))-SUM((K9:K72/L93))

View 9 Replies View Related

Count Unique Values With Multiple Conditions Array Method

Apr 28, 2014

I need to modify the underneath Count Array Formula to count unique values based on multiple conditions. I can get the formulas to work with NUMERIC values in Column A in the N1 & N2 tabs. However, I cannot get the formula to work when column A contains TEXT values in the TX1 & TX2 tabs.

I've attached the XL file for your review of the project.

=SUM(IF(FREQUENCY(IF(('TX1'!$B$2:$B$15=B2)*('TX1'!$C$2:$C$15=C2)*('TX1'!$D$2:$D$15=D2),MATCH('TX1'!$A$2:$A$15,'TX1'!$A$2:$A$15,0)),MATCH('TX1'!$A$2:$A$15,'TX1'!$A$2:$A$15,0))>0,1))

View 4 Replies View Related

Multidimensional MI Analysis

May 11, 2009

how to tackle a piece of work that I really don't want to do.

We have extracted some summary information on one of our products. The workbook has 10 sheets, one for each of our 10 main sales channels. Each sheet has the same layout of information on. There are 7 tables on each sheet, and each one cuts the data in a different way (eg one summarises by age of purchaser (in age bands), another by demographic group etc). Each table then has the same 14 columns of key data (eg number of sales, average order value).

I've been asked to analyse this information "for anything interesting". At the moment, the only way I can think to do this is to print out the 10 sheets, sit down with a highlighter, and try to visually identify trends and anomalies. The idea fills me with dread, and I suspect will be quite inefficient.

I've asked whether I can get the data in a pivot table or some other format that might be more conducive to analysis, and have been told no. (There will easily be more than 100,000 lines in the original data (we're using Excel 2003)). To be honest, I'm not sure that I'd really be that much better off, even if it were in a pivot table.

View 9 Replies View Related

Limit Listbox Multidimensional

Feb 14, 2009

if someone have a code for filter o limit a Listbox but with 6 columns and 6 textbox because i have a code but is only onedimensional works fine but i dont have any clue how to modify to works like multidimensional

this the one dimensional
Private Sub tbxFind_Change()
Dim vList As Variant

'Read the original list
vList = Range("A2", Cells(Rows.Count, 1).End(xlUp)).Value

'Convert it to a 1D array
vList = Application.Transpose(vList)

'Filter it
vList = Filter(SourceArray:=vList, _
Match:=tbxFind.Value, _
Include:=True, _
Compare:=vbTextCompare)

'Send it to the listbox
lbxCustomers.List = vList

End Sub
Private Sub UserForm_Initialize()
'Read the original list
lbxCustomers.List = Range("A2", Cells(Rows.Count, 1).End(xlUp)).Value
End Sub

View 9 Replies View Related

Array For Filter In Pivot Table?

Dec 11, 2012

How to use an array of multiple values ​​in code I want to use the array of values "jan" "feb" "mar" in the code instead of "jan"

Code:
Private Sub Worksheet_Activate()
ActiveSheet.PivotTables("Pivottable1").PivotCache.Refresh
ActiveSheet.PivotTables("Pivottable1").PivotFields("cat").ClearAllFilters
ActiveSheet.PivotTables("Pivottable1").PivotFields("cat").PivotFilters.Add _
Type:=xlCaptionDoesNotEqual, Value1:="jan"
End Sub

View 2 Replies View Related

How To Filter Data By Array Formula

Dec 23, 2013

My Sheet1! looks like (image attached)

On Sheet2! i want to import all rows belongs to Nov-13. Similarly on Sheet3! all rows belongs to Dec-13 ... How to do such dynamic filter using array formula?? I need array as my data source is a form & new rows will be added everyday. I want to do that by formula not using spreadsheets 'Filter" option.

Expected result will looks like below (All Nov-13 rows will return)

View 3 Replies View Related

VBA To Output From Array Based On Variable In One Element Of Array

May 2, 2013

I'm only starting to get to grips with arrays. I have what I consider to be a lot of data that I need to 'cut' into separate workbooks. I have written some code that does this by simply looping through each line, 250k+, checking against a variable and copying the row into a separate sheet. This took longer than it would have doing it manually. It was suggested to me that I use arrays to speed up the process. I have managed to store the test data into an array but am struggling to find a way to loop through and pull out an entire 'row' from the array based on a variable. I have looked for 2 days in various places to find some way to loop through the data held in the array, but to no avail.

That code will appear here from about 8am GMT tomorrow. I know that once I've cracked this I'm on the road to some very significant time saving and comprehensive report writing.

View 9 Replies View Related

(Auto)Filter With Dynamic Array For ComboBox **

Jun 28, 2007

(Auto)Filter or a listbox somehow functioning like it?

Hi Excel guru's, i've got the following question:

Can I fine-tune the AutoFilter function so it filters more flexible? ....

View 9 Replies View Related

Advance Filter Statistical Array Formula

Apr 13, 2008

I have many large arrays of climate data. I am trying to find an array criteria formula that would filter out those years from a variation around a given year. Like this example, to filter out those years B10 (47.8) plus or minus B12 (3.339).

AB
1YEARTEMP
21870 44.78
3187143.33
4187240.99
5187339.43
6187440.94
7187537.33
8187642.23
9187745.68
10187948.18
11
12Stdev3.339

View 9 Replies View Related

Store Unique Filter Values Into An Array

Jan 21, 2009

In an excel i have 3 columns they it contains around 12000 records

Group FA Title
A S1 bbbb
A M1 xxxx
A M2 eeeee
A S1 ffffff
A S1 pppp
A M3 aaaaa
A M2 ooooo
A M2 qqqq
A M1 ttttt

Here i need to get the unique FA, so i filter the column FA, my question is, After filter with FA column ,is there any way to store these unique FA(ie S1,M1,M2,M3) into an array using vba?

View 9 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved