MaxIf Across Discontinuous Range - VBA Or Formula

Sep 6, 2013

I want to create VBA code, or a formula that achieves MaxIf across a Discontinuous Range.

I already have the basic Max If array formula which works in another place:

{=MAX(IF(EditAsset_MaintenanceType="Scheduled Maintenance",EditAsset_MaintenanceDateUndertaken))}

Where each named range is a column of 20 continuous cells.

This actually sits within a larger formula {=IF(MAX(IF(EditAsset_MaintenanceType="Scheduled Maintenance",EditAsset_MaintenanceDateUndertaken))=0,EditAsset_DatePurchased+(EditAsset_MaintenanceCycle*30.4167),MAX(IF(EditAsset_M aintenanceType="Scheduled Maintenance",EditAsset_MaintenanceDateUndertaken))+(EditAsset_MaintenanceCycle*30.4167))}

Now I need to achieve a similar thing, but in a master list of all the data which necessitates a different layout so the data can't be in 2 columns, and can't be continuous. So:

Max the dates in cell BE7, BI7, BM7, BQ7, BU7, BY7, CC7, CG7, CK7, CO7, CS7, CW7, DA7, DE7, DI7, DM7, DQ7, DU7, DY7, EC7...

...IF the value of the corresponding cell two columns to the left of each is "Scheduled Maintenance",

e.g. cells BC7, BG7, BK7, BO7, BS7, BW7, CA7, CE7, CI7, CM7, CQ7, CU7, CY7, DC7, DG7, DK7, DO7, DS7, DW7, EA7

I tried creating 2 named ranges (one for the cells in each bullet point above) and using that in the array formula, but that didn't work and as this formula needs to go down 8,000 rows it would require 16,000 named ranges which isn't really practical.

Ideally I think I would perform this calculation in VBA and just output the answer to the relevant cell. [The VBA code will be triggered via a Worksheet_Change event when one of the date cells, or the 'maintenance cycle' cell elsewhere is changed].

I think this could be done by taking the values from the cells above into two arrays, and then 'max if' those arrays within VB somehow - but I don't know how to create the arrays or then perform 'max if' within VBA.

Alternatively a formula would suffice - I could insert this formula into the output cell via the VBA Worksheet_Change event when an input cell (date or maintenance cycle) is changed, and then have the same VBA code copy this cell and paste the value - can't have up to 8,000 array formulas live in my sheet for performance reasons! But I don't think this will be easily possible via a formula and VBA would be cleaner.

View 7 Replies


ADVERTISEMENT

Find Address Of MaxIF In A Range

Apr 4, 2007

I am having troubles with using two methods together. I know how to find the address of the first or last occurance of a MAX in a range. I also know how to create a MAXIF function using criteria to determine what to consider for the max calculation. I do not know how to return the address of the result from the MAXIF.

I am using Office 2003 on WinXP.

Ultimately I want to take the address of the first result of a MAXIF and use it to do a lookup for a corresponding value. I'm not sure if I will be able to do this with a combination of functions, or if I will need a macro.

Heres an example:

Data:
Time WeekNum Count
01:02 1 12
02:05 1 35
03:09 2 456
14:20 2 123
12:24 2 122
Usage:

Use the maxif lookup to return the time of the largest count for WeekNum 2

Result:
03:09

View 9 Replies View Related

Selecting A Discontinuous Range

Sep 22, 2006

I'm trying to select a discontinous range, lets say B2:B30 & D2:D30 and this works fine using the code below:

Range("B2:B30,D2:D30").Select

However if I use the code below, B2:D30 is selected including column C.

Dim LastRow As Integer
LastRow = Range("a65536").End(xlUp).row
Range("B2:B" & LastRow, "D2:D" & LastRow).Select

View 2 Replies View Related

Set Discontinuous Range Of Columns As CopyRange Using VBA

Jan 28, 2014

I have this code to set a copyrange, which is throwing up a 'Wrong number of arguments' error

[Code] .....

Correct syntax for the code?

View 2 Replies View Related

MaxIf Function

Oct 20, 2009

I would like to write a formula that looks at the last month with a percent value greater than zero, then return the percent value in a specific cell. In the example below I want to display 85.0% in the cell. It should update each time data is entered for the following month.

Here is the source:

MonthPercentage
October 96.0%
November 2.0%
December 70.0%
January 85.0%
February 0.0%
March 0.0%
April 0.0%
May 0.0%
June 0.0%
July 0.0%
August 0.0%
September 0.0%

View 9 Replies View Related

Maxif Function In Vba

Nov 10, 2004

I want to write a reuseable maxif function in vba. The following code is working when entered directly into the cell:

= SUMPRODUCT(MAX((B1:B6=B2) * (A1:A6)))

Now I want to pack this function into vba code to make it commonly available. I tried it with the following code but it doesn't work. I assume there is a problem with the passing of the range parameters. I also tried it with String and Variant as parameter types - without success. Can anybody help me?

Public Function MaxIF(criteriaRange As Range, searchValue As Variant, calcRange As Range)

AciveCell.Formula = "=SumProduct(Max((criteriaRange = searchValue) * (calcRange)))"

End Function

View 5 Replies View Related

MAXIF And MINIF Functions With Wildcards

Jul 16, 2009

I have a list of bank transactions in a spreadsheet

for example....

1/7/09 Sainsburys Petrol 34856385
4/7/09 Paypal 92017465
6/7/09 Sainsburys S/Market 38264059
8/7/09 Halfords 93862830
11/7/09 Sainsburys S/Market 34957372
13/7/09 Paypal 92037454
14/7/09 Barclays BCC 173256

and wish to use formulae similar to MAXIF and MINIF to find the last date and the first date of Paypal transactions (for example) if I have just the word "Paypal" in cell D1

I've tried
=SUMPRODUCT(MAX(($B$1:$B$7=$D$1)*$A$1:$A$7))

but obviously this is looking for exact match of "Paypal"

I have successfully used a wildcard in SUMIF functions elsewhere...

eg, $D$1 & "*"

but for some reason
=SUMPRODUCT(MAX(($B$1:$B$7=$D$1 & "*")*$A$1:$A$7))
does not work

Does anyone have any suggestions?

View 12 Replies View Related

Discontinuous Time Series Charts

Apr 21, 2008

I just joined ozgrid and this is my very first post. I have read the rules but spare me if I make some errors.

My question is related to plotting time series charts using VBA. I have data in the following format.

04/21/08 9:04:47 4.5055
04/21/08 9:04:48 4.5055
04/21/08 9:04:49 4.5055
04/21/08 9:04:49 4.5055
04/21/08 9:04:50 4.5055

04/21/08 10:05:00 3.5055
04/21/08 10:05:32 3.5055
04/21/08 10:05:40 3.5055
04/21/08 10:05:48 3.5055
04/21/08 10:05:51 3.5055

04/21/08 11:07:59 5.5055
04/21/08 11:09:00 5.5055
04/21/08 11:10:01 5.5055
04/21/08 11:11:02 5.5055
04/21/08 11:13:08 5.5055
04/21/08 11:14:11 5.5055
04/21/08 11:15:16 5.5055

The column on the left is NOW() output and the one on the right is data corresponding to the given date and time. You may interpret the above data as snapshots taken at regular time intervals.

Now what I want to do is make a chart with the above data. Where ever there is a break in the snapshots, represented by a blank line, I want the graph to jump to the next data point much as the way stock prices move from the closing price to the opening price on the next day. I am not able to figure how to do that. Since I want the x-axis to represent time, using scatter charts does not work since the intervals are not proportional to the time then.

View 9 Replies View Related

Selecting Multiple Discontinuous Columns With Two Lines Titles

Jan 24, 2014

I have quite a long sequence of column for which the headers are all two-lines titles (with a line break). I need to copy many columns that are discontinuous, and the operation would save me a lot of time if I could select them at once. Of course, I know about selecting the columns holding CTRL, but here is the snag: as soon as a two-line title column is selected, the formula bar displays the content of the header, obviously on two lines, and I can't select any more columns. I tried many things, but nothing could solve this...

Is there anything I can do besides copying the columns one by one (which would take a long time) or renaming them?

View 1 Replies View Related

Setting Variable, Discontinuous Print Area In A Macro

May 29, 2009

I need to write a macro to set the print area to the first two columns (A & B), and the last 12 columns (the last column may change). In both cases I need to print all rows (start is row 1, last row is variable). I am trying to achieve something like the "Freeze Pane" effect with the printer. The first two rows contain column headers (dates). The first two columns contain information that needs to be included on the printout, whilst the last 12 columns contain the most recent data.
Various cells withing the selected ranges may be blank, but no row or column will be entirely blank.

View 2 Replies View Related

Auto Copy From Upper Cells In Discontinuous Data In Column

Apr 9, 2013

I have a column with data but some rows are empty, i want the empty rows to be filled with exact data from the upper cell so that no row remains empty. How can this be achieved?

View 4 Replies View Related

"MAXIF" Function, Or Equivalent?

Dec 1, 2008

I have a spreadsheet that I'm working on that compiles survey data from an online survey. I have averages, high scores, low scores, etc. figuring off of my data to product charts and graphs for a client. I am attempting to find the high and low scores for individual surveys (there are 1054 surveys total right now). I know of max and min, but I really need something that would function like a "maxif" (which I realize does not exist).

Here's the problem:

In column A, I have a list of insurance provider names per survey (so, 1054 entries total). I then have some columns in between that show scores on questions from the survey, and then column AB contains my averages for each individual survey. Column AD has a list of the insurance provider names in alphabetical order (there are 167 unique provider names used in the 1054 surveys). Column AF is my high score column and lines up with column AD (so, I am looking to have 167 high scores in total as I want the high score per each provider, not survey). Let's pretend A2:A10 say "Anthem Insurance." I want to create a formula that would basically say something like:

Count what rows in column A = "Anthem Insurance," then match those cells to AB (so, it would figure since A2:A10 are the targeted cells, then I also want to correspond to AB2:AB10) and give me the high score (MAX) for that range of cells. Is there a way to do this? Otherwise, I have to manually go through all 1054 rows and see what range of cells equal a certain insurance provider name to get those 167 high scores. I can keep doing this if I have to, but this data changes every single week and it eats up a lot of time.

View 4 Replies View Related

Flexible Range Formula: Return The Minimum Value From A Column Range

Feb 9, 2010

I need a formula that will return the minimum value from a column range that flexs without having to manually go in an change row references. There is a blank row between each section of data in order to separate info. As an example:....

Need to formula to flex to include rows 5 thru 7 in the first section but expand to include rows 9 thru 13 in the second section. =MIN(A5.A7) works but how do I get next section to flex to =MIN(A9.A13) without manually changing the cell references? There is always a blank row in between the sections to separate.

View 5 Replies View Related

Formula That Will Recognize Date Range And Sum Specified Field Based On Range?

Jan 2, 2014

I like to create "templates" for files that I work with on a reoccuring basis, just to make things simpler. The current template I am working on tracks items processed by day and is used for two reporting purposes; 1 totals the pay ending items processed so I have the dates laid out based on the 2 week period with formulas for that. The 2nd way it is reported is by the month. Since this is a template, only the first day of the first pay period for a calendar year needs to be entered and the rest of the dates populate based on that date. What I would now like to do is add columns for January - December monthly totals using a formula that will read something like "if column A (where the date is) contains 1/1/2014 - 1/31/2014, then sum up column L" and than copy that formula for the remaining months.

View 8 Replies View Related

Get The Range Address Of A Dynamically Named Range That Refers To A Formula In VBA

Aug 10, 2008

I have a named range that expands and contracts based upon the amount of data that is in some column. Call it AllData_UsedRange.

I have another named range that actually refers to a range. Call it AllData.

Column A
Row2 56
Row3 44
Row4 65

AllData is a named range that refers to the range A2:A65536
AllData_UsedRange refers to A2:A4 by way of this formula.
=OFFSET(AllData,0,0,COUNTA(AllData))

How to I obtain an address of AllData_UsedRange in VBA code?

These do not work...
ThisWorkbook.Names("AllData_UsedRange").RefersToRange.Address
Evaluate(ThisWorkbook.Names("AllData_UsedRange"))

View 9 Replies View Related

Stop Graph From Changing Named Range To Formula Range

Sep 8, 2006

I am trying to create a graph for a range of data that updates monthly (adding an extra month each time). I wanted the graph source data to update automatically each time the data is refreshed so used an OFFSET formula to identify a named range. I then point the graph to the named range as the source data.

When I enter the range as the source data the graph picks it up. However, when I re-enter the source data option on the graph it has converted the named range into a cell written range (ie. replaces "=QUALITY" with "='Front page'!$B$7:$J$10" - which therefore will not update when the range increases.

View 4 Replies View Related

Calculate The Range And Fill With A Formula Using The New Range

Apr 1, 2009

I have a range of values that are not a constant length. I want a macro that will calculate the range and fill with a formula using the new range. In this example, I need a formula to look at the values in range f464:f471 and calculate the number of values greater than $1000. Column B is a salesman identifier. I can do this manually, but it takes me about 1/2 hour to complete. At every change in "B", I need to place this formula in the open, blank cell in "E" such as highlighted below.

week39

ABCDEF45939SCHTERR-WIEDEMANNDCCDIST-MUSCHANY046039SCHTERR-WIEDEMANNDCCDIST-MUSCHANY046139SCHTERR-WIEDEMANNDCCDIST-MUSCHANY046239SCHTERR-WIEDEMANNDCCDIST-MUSCHANY0463 SCH Total 14042.2146439SCITERR-SULLIVANDCCDIST-MUSCHANY15587.1546539SCITERR-SULLIVANDCCDIST-MUSCHANY7217.2246639SCITERR-SULLIVANDCCDIST-MUSCHANY5316.6246739SCITERR-SULLIVANDCCDIST-MUSCHANY2720.6946839SCITERR-SULLIVANDCCDIST-MUSCHANY520.446939SCITERR-SULLIVANDCCDIST-MUSCHANY195.7147039SCITERR-SULLIVANDCCDIST-MUSCHANY047139SCITERR-SULLIVANDCCDIST-MUSCHANY0472 SCI Total 31557.7947339SCJTERR-VANBUSKIRKDCCDIST-MUSCHANY4190.7147439SCJTERR-VANBUSKIRKDCCDIST-MUSCHANY3219.7647539SCJTERR-VANBUSKIRKDCCDIST-MUSCHANY3187.147639SCJTERR-VANBUSKIRKDCCDIST-MUSCHANY2209.3747739SCJTERR-VANBUSKIRKDCCDIST-MUSCHANY2132.7547839SCJTERR-VANBUSKIRKDCCDIST-MUSCHANY2034.56
Spreadsheet FormulasCellFormulaF463=SUBTOTAL(9,F435:F462)F472=SUBTOTAL(9,F464:F471)

Excel tables to the web >> http://www.excel-jeanie-html.de/index.php?f=1" target="_blank"> Excel Jeanie HTML 4

View 9 Replies View Related

Formula To Compare Sum Of Range To Cell Value And Return Cell Count Of Range Used

Jun 3, 2014

I am trying to find out how many weeks our current inventory will support our sales. I am trying to research formulas that will do this, and coming back with things like OFFSET, MATCH, INDEX but am not certain the best way to put them together to get what I need. I use excel daily, but this is a bit mroe advanced than I am used to

Mini.xlsx

Starting in cell B4, I would like to count how many weeks of Demand can be covered by the specific Available On Hands in row 3 for that week, put the number of "Weeks Covered" into cell B2, and then fill over to the right in row 2. Right now, the values in row 2 are from my own manual calculations, but I would like a dynamic formula that will sum up the values in row 4 up to (but not greater than) the value in B3, give the count of cells that reached that sum (or even better with decimals to show the percentage covered), which I will copy over into B3:B13. Not sure if that makes sense, or if I can explain in a better way. The yellow cells are what I am trying to create a formula for and am currently stuck.

View 6 Replies View Related

Formula To Average Range Of Cells And Copying It To Calculate Next Range Of Cells?

Mar 17, 2014

I have a row data corresponding to the measuring of load cell per min and I need to average the values per hour. So I have a column B for the date (from 1-01-2013 to 31-01-2013, column C for the time (0:00:00 to 23:59:00), and D de values per min I want to average. I have to do the same for the rest of the month of 2013 (February, ...., December).

I would like to know if there is a way to create a formula to calculate the average of the first 60 values (to get the average of the first hour of 1-01-2013), and then copy it to get the average of the following 60 (average of the second hour in 1-01-2013) and so on.

If there is no way to do it, I would like to know if I can do it using functions like average, match, index, offset, what would be the best match of those functions.

I also tried it by doing the analysis in another tab and using the function "averageifs" with two criterias: one for the date (example 01-01-2013) and another one for the hour (example 0:00:00), but it didnt work, it show error: #value. I inserted an extra column in the data tab with just the hour (example 0:00:00) in front of the corresponding column with (example 0:01:00, 00:02:00, etc)
Equation I used for this:

=AVERAGEIFS('Data (min)'!D$6:D$43206,'Data (min)'!$A$6:$A$44646,A6,'Data (min)'!$B$6:$B$44646,B6)
=AVERAGEIFS(TAB AND COLUMN WHERE THE RAW DATA IS,RANGE OF CRITERIA 1,CRITERIA 1,RANGE CRITERIA 2,CRITERIA 2)

View 2 Replies View Related

Formula But With A Range

Mar 5, 2014

Needed a formula in sheet1 in column D where if in sheet2 in column J when the cell value is in the range from 50 to 100 then the cell value in sheet1 column D becomes 0.

The range from 50 to 100 means starting from 50 it can be any one number till 100.

The formula will be pulled down in D column upto the required length.

View 14 Replies View Related

Range Name In Formula

Dec 26, 2007

=SUMPRODUCT(('DVP Trades'!$B$2:$B$1000="LOAN")*('DVP Trades'!$C$2:$C$1000=A31)*('DVP Trades'!$A$2:$A$1000=FUNDS_SS)*('DVP Trades'!$F$2:$F$1000))

Maybe this is impossible, someone let me know.

I am using the above formula. I am trying to use range names where its bolded in place of repeating different cells. However my the result of the formula is N/A.

The range name of "Funds_SS" is a group of 12 funds. What I want to do is take the total of anything that is a Loan in column B, with a given client in column A, if it occurs in any of the funds in range name FUNDS_SS, and the value of the loan is in column F. Does anyone know what I am talking about? Can it not be done? I don't know if I can explain it any better.

View 9 Replies View Related

Formula: Within A Certain Range

May 22, 2009

I m writing a formula so that if the value in a cell is within a range, it will have a value other than 0.

The formula I'm working on is:

View 2 Replies View Related

Range Name In A Formula

Mar 20, 2007

I'm trying to refine my code a bit so I don't have to re-write when my list data changes. How would this code be modified to use a dynamic range name? I have created the range name on the other worksheet using this code in the refers to box of the define name drop down.

View 14 Replies View Related

Range Formula Using VBA

Nov 2, 2007

In a cell named item I have a text "unit price".
In a cell named unitprice I have a number 3.45.
In a cell named linetext I have a text "=concatenate(item;unitprice)"
Is it possible to use range.formula to do this using VBA? Is there another way to do this?
I need this type of solution because the formulas in linetext will change based in other cells.

View 14 Replies View Related

If Formula For A Range

Oct 7, 2009

I have a range of cells, D14:IG14, that may or may not have the words "Full Redemption" in each cell. If any of the cells has full redemption, I want "full" to appear in cell II14.

I'd like to do this via formula, but am having trouble with the fact that it's a range I want to look it.

View 9 Replies View Related

Formula To Sum Range

Oct 9, 2009

A1: =""
A2: =Text(2,0)

I try =SUMPRODUCT(--(A1:A2)) and CSE Formula =SUM(VALUE(A1:A2)) the result is #VALUE!

What is the formula to sum range A1:A2 which the result is 2

View 9 Replies View Related

Vba Range.formula

May 10, 2007

I'm trying to develop an automatical update function for a workbook. I have a workbook, in which I want to updates some formulas. In this regard, I've set up an Add-In. The problem is that when using *. range.formula an error occurs. I understand why this error occurs, but can not mangage to find a solution to solve my problem. The code I'm using follows:

Public Sub DoToAll()

Dim ws As Worksheet

Application. ScreenUpdating = False

For Each ws In Worksheets

ws.Range("B15").Formula = "=IF(D12<>"Age","",IF(AND(YEAR(MID(D9,14,10))=YEAR(TODAY()),MONTH(TODAY())>=7)=TRUE,"Do Nothing",IF(MONTH(TODAY())>=7, DATE(YEAR(TODAY())+1,1,1),IF(MONTH(TODAY())<=6,DATE(YEAR(TODAY()),7,1))))) "

Next

Application.ScreenUpdating = True

End Sub

I have several similar ws.range.formula codes I want to use.

Does anybody know how to insert such formulas via VBA?

View 4 Replies View Related

VBA Used Range With Workbook In Formula

Nov 20, 2013

Coming from this formula in vba :

VB:
Dim sh As Worksheet
Set sh = Worksheets("Data helper")
Set Rng = sh.Range("C2:C" & sh.Range("C" & sh.Rows.Count).End(xlUp).row)

I want to translate this to a workbook dependent formula, but I'm not sure what I'm doing wrong

VB:
Dim book1 As Workbook
Dim sh As Worksheet
Dim srchRange As range '(added this line in edit : still not working)

'Set some variables:

[Code] ....

View 9 Replies View Related

AVERAGEIFS Formula With A Range?

Aug 11, 2014

I've been trying to use the averageifs formula to determine the aveage FTE needed for 1st, 2nd, 3rd, 4th and years beyond for different client types. Column A displays the client type, Column B the number of years live and Column C is I've come up with the following formula but I can't seem to get it to work right.

=AVERAGEIFS(C2:C16,A2:A16,"C",B2:B16,">=0",B2:B16,"<1")

ClientYearsFTE
C3.612.49
P-0.00
P4.610.16
M0.940.00
M3.280.57
P0.940.00
C-0.06
C3.610.51
C3.450.29
P3.124.18
C4.121.58
C5.371.25
M4.120.63
P7.290.36
M2.611.27

View 3 Replies View Related

IF Formula For Range Of Data

Jan 12, 2014

Please refer to attached sheet.

I have number 10000 to 10200 in column D.

I need to use IF Statement and add corresponding number in Column A as follows.

IF D2 = 10000,10006,10012,10018,10024 and so on then A2=20002
IF D2 = 10002,10008,10014,10020,10026 and so on then A2=20003
IF D2 = 10004,10010,10016,10022,10028 and so on then A2=20004

(Basically there is increment of 6)

Once i have formula for A2 then i can copy down the column.

Book1.xlsx‎

View 8 Replies View Related







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