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


ADVERTISEMENT

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

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 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

Slicing And Dicing CSV Files - Involves Arrays And Jagged Arrays

May 8, 2013

I am retrieving a CSV file from the net. In this file there are 'x' amount of row data and 7 columns. I only care about the values in the 7th column for each row. I also don't care about the entire first row. A graphical version would be represented something like this, with the values I want colored in orange:

|---,---,---,---,---,---,---|
|---,---,---,---,---,---,---|
|---,---,---,---,---,---,---|
|---,---,---,---,---,---,---|
|---,---,---,---,---,---,---|
|---,---,---,---,---,---,---|
|---,---,---,---,---,---,---|

.
. extending until the end of the data set
.

I've managed to dice this thing into a jagged array by first splitting it using vbLf as a delimiter, and therefore adding those to an array called Lines(). Then I split Lines() up using commas as the delimiter and threw those into a jagged array, let's call it Breadcrumbs()(). I want to throw all the values from Breadcrumbs(i)(6) into an array of its own. Here's my code so far:

Code:
Public Sub CSVparser(file As String)
Dim Lines As Variant
Dim j As Integer
Lines = Split(file, vbLf)
ReDim breadCrumbs(UBound(Lines)) As Variant
For i = 1 to UBound(Lines) - 1
breadCrumbs(i) = Split(Lines(i), ",")
Next i
End Sub

View 1 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

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

Sum Based On 2 Conditions

Dec 1, 2007

I want to have SUMIF and IF functions to be combined. i tried using the formula SUMIF( Timesheet!D2:D55,B2,Timesheet!F2:F55) but i want to edit the range everytime.
Can i have formula like if name = Ant merce and prj = Implementation support, then the sum will be 15 for the sumrange of Timesheet!F:F (entire F column)

View 4 Replies View Related

VLOOKUP Based On Two Conditions?

Aug 16, 2013

My challenge is pulling in a data element from a file to an exisiting file based on two criteria.
Example: give me the value in cell e1 if cell b1 matches AND

File 1
A B C
1 H12377 03/05/2013 123
2 H12377 03/27/2013 276
3 H32389 05/03/2013 335

File 2
H12377 03/27/2013 _________

how do I get C2 value from file 1 (276) into file2 since column A is not unique but column A plus Column B is unique?

View 5 Replies View Related

Average Based On Conditions?

Jul 1, 2014

I have attached a file where there is information in the sheet Weekly with the first row showing the same month for several weeks. add a formula in the sheet Monthly which would calculate average for each month based on the first row in Weekly sheet. Plus the grouping in the Weekly sheet is done by shops and in the Monthly sheet by food, which would I imagine make the formula more complex.

View 5 Replies View Related

Lookup Based On A Few Conditions

Mar 13, 2008

I am wondering if I can do a formula that would tell me if the name that appears in column J or K appears more than once at the time/date slotted in columns A and B. Basically, I want to make sure that the name(s) in column J and K aren't assigned 2 different places at the same time slot (column B) on the same say (column A).

View 9 Replies View Related

Sum Based On Multiple Conditions

Aug 28, 2009

I am trying to sum numbers based on three counditions.

My problem the third condition needs to use a wild card. I have attached a sample file, in the last condition I am only wanting to sum numbers where the characters in the last column begins with bd*

The yellow cell contains the formula I am using.

View 4 Replies View Related

Sum Based Conditions In Different Sheets?

Dec 11, 2012

I'm creating stockportfolio's based upon historical stock data. I have 300 stocks with monthly observations. Stocks are assigned to a portfolio based upon their return in the previous 6 months. I need the top 10% stocks in terms of return in previous 6 months (so 30 stocks) in one portfolio and the lowest 10% stocks in terms of returns in previous 6 months returns (so again 30 stocks) in another portfolio. Each portfolio is just a sum of the returns of the stocks that are in there.

First sheet: rows contain the return a stock had in the 6 months before the month in the left column (so january 2006 contains the return a stock would have had from july2005 -december 2005). This is done for 300 stocks. Second sheet: contains the return the stock had in that actual month (so january 2006 just contains the january 2006 return) The third sheet is where I want to create the decile portfolio's. This means that for every month i am creating 10 portfolio's: Each month "portfolio 1" should contain the sum of the returns of the stocks with the 30 highest returns in the past 6 months. "Portfolio 10" should contain the sum of the returns of the stocks with the 30 lowest pas 6 month returns. (30 is 10% of 300: that's why it is called decile portfolio)

So I should sum things from sheet 2 with the condition referring to sheet 1 where the returns of the past 6 months are displayed. I am trying formula's like =SUMIF(RANK...) but am getting no results. Somehow excel should select the right stocks and sum the 30 returns. I'm totally lost after a lot of trials.

View 1 Replies View Related

Adding Based On Certain Conditions?

Mar 6, 2013

I am doing a financial analysis for a hospital. I want to know how to add something to a number based on conditions. Base pay is $300 for the first 10 patients. If more then ten patients >11-20 add 40 dollars per visit if greater than >21 add 50 dollars per patient

View 3 Replies View Related

Get A Result Based On Several Different Conditions

May 20, 2009

New to the forum and in need of a bit of help. Friend of mine is in here regularly looking for assistance and tells me this is the best excel forum around. Thought I would put it to the test with a problem that is doing my head in.

The following is a table which shows a salesmans sales. He or she has sold to 8 customers.

What I need to do is show in the commission column how much they should get paid for the additional products based on this criteria.

1. If the penetration is equal to or over 41%, and he has sold the additional product for max profit of 250 then he should get £40

2. If the penetration is less than 41%, and he has sold the additional product for max profit of 250 then he should get £25

3. If he hasnt sold the product for full amount then he gets 10% of the profit, regardless of the penetration ...

View 6 Replies View Related

Lookup Based On Two Conditions ...

Jul 13, 2009

I know that there are bunches of threads concerning lookups with multiple criteria, but I just can't figure out how to translate one to my situation. I want to return a value based on an item name which is in column A, and an operation which is in row 1.

The array from which I need to look up the value contains part number in column B, operation in column G, and the actual value I need returned in column H.

So I need to return something like this: ...

View 14 Replies View Related

Sum Based On Hundreds Of Conditions

Aug 3, 2012

I am tasked with making a matrix that I cant seem to solve.

I have solved it on a small scale using

=SUMPRODUCT($E$5:$E$19,--ISNUMBER(SEARCH(O11,$C$5:$C$19)),--ISNUMBER(MATCH($D$5:$D$19,{"One","Two","Three"},0)))

The issue is that I need where {"One","Two","Three"} is to contain between 3 and 334 conditions.

Basically we have a data table that contains "channels" that have multiple affiliates under it. Then we have a data table by affiliate by country and revenue... I want revenue by Country By Channel...

View 3 Replies View Related

Popup Based On Two Conditions

Sep 25, 2012

I have this vb script which basically states if a value in column G is less than 0 then show a message box as below.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count 1 Then Exit Sub
If Not Intersect(Target, Range("G3:G371")) Is Nothing Then
If Target.Value < 0 Then
MsgBox "You have entered a negative figure - are you sure this is correct?"
End If
End If
End Sub

What I would like to do is extend this script so that another message box pops up based on two conditions

i.e. if a cell in column F shows string "accounts use only" AND value in the adjacent cell in column G is > 0 then MsgBox "you have entered a positive figure - are you sure this is correct?"

View 5 Replies View Related

Macro With If / Then Based On 3 Conditions

Aug 10, 2013

I'm trying to adjust my macro to fill the interior cell color of a row if there's a non-blank row above and below it (i.e. if there are 3 or more non-blank rows together, then fill the 2nd, 4th, etc. rows. If there are only 1 or 2 rows together, then don't fill the cells.

However, what I'm getting is filling ever other row, with this code. There seems to be an error in how I'm trying to use and If condition with 3 criteria.

Code:
Sub colorin()

Dim LastCol As Long
Dim r As Integer
r = 6
With ActiveSheet
LastCol = .Cells(5, .Columns.Count).End(xlToLeft).Column

[Code] ....

Here are some sample results (pretend cells with red text are actually cells with interior color, black text is an unfilled cell).

Rank
Name

1
Jones, Some

[Code] ......

What I'm trying to achieve is: (again, red text actually represents filled cells - can't get sample shot of actual filled cells to copy into forum post).

Rank
Name

1
Jones, Some

[Code] ...........

View 6 Replies View Related

Display Value Based On 2 Conditions

Nov 6, 2009

I have a workbook with 2 worksheets. The first sheet provides a summary showing the last date a person attended a specific course.

The second worksheet is a list of all courses, attendees, dates, and status. I need a function that will match the attendee and course from the Master and display the date from the master in the corresponding cell on the summary sheet....

View 9 Replies View Related

Lookup Based On 2 Conditions

Dec 22, 2006

In the sample that I have attached. I am trying to compare Control ID and Business Date in Sheet[Test] and Sheet[Perform], If they are the same, then populate in Sheet[Perform] Column Test Status with the corresponding row in Sheet[Test]. note that Control ID and Business Dates are not constants.

View 4 Replies View Related

Add Sheets Based On Conditions

Dec 29, 2006

i am not able to solve this problem.

1- I have 3 tabs in this worksheet with the data - Tabs A , Master Data and refernce Table

2- Suppose column K in the tab " Master Data " has a record or number, they can be repeated as the new data us added every month.

3- Reference table has the list of the same data record ( numbers ) .

Now the situation is if there is a new record in the column K of the master data sheet the Macro should do the following.

a- Check for the record in the reference table , if doesnt exist then add the record in the reference table

b- create another sheet same as the sheet " A" (duplicate of
A) and name it the new record number

b- Plug the new record number in the cell B2 of the new sheet

c - Copy the row 8 from ( D8 to O8 ) in the new sheet from (D8 to
O8)from sheet A

View 5 Replies View Related

Extract Certain Data Based On Conditions?

Sep 25, 2012

I created a master data sheet to enter data manually to analyze. It contains 20 columns, and rows(continue change, because we enter data all of the days). I need to extract data to another sheet, when the user enters data in the master data sheet, but with some conditions, when the column 6 contain the word ASQ, and then extract all of the data, but the new sheet do not contain 20 columns, because the data that contains the word ASQ have only 16 columns.

View 6 Replies View Related

Extract Certain Data Based On Conditions

Sep 28, 2012

I need to create a macro to extract data from sheet1 to sheet2.

The sheet1 contains 15 columns, and the data starts at row 5.
The sheet2 contains 15 columns, and the data starts at row 5.

We enter data all of the days, so we have like 500 rows in the sheet1.

Only 2 conditions to extract data from sheet1 to sheet2:

if the column9 of the sheet1 contains the word "NO" and column11 of the sheet1 contains the word "ASQ".

View 4 Replies View Related







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