IF with variable range

kala

Board Regular
Joined
Nov 6, 2002
Messages
65
Hello! I can't find a similar question, so posting a new thread.
Problem: I want to create a SUMIF or MAXIF statement where the range will vary depending on when the first data point starts but the formulat must have 52 columns in each. For example, the range in row 1 would start from Col A and go to Col AZ. The range in row 2 would start from Col D and go to Col BC. The range in row 3 would start in Col B and go through Col BB.

..........A..........B...........C..........D..........E..........F..........G..........ETC
1........2..........4..........100.......200.......225.......1000.....3000.......ETC
2.....(blank)...(blank)....(blank)....40........60.........5000.....8000.......ETC
3.....(blank)......30.........4..........40.......400........300.......2000.......ETC

Can anyone help? Thank you!
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Does the formula that provides the address need to fit in a single cell, or do you have some flexibility as to assigning intermediate cells to hold progressive values that will 'build' the address?
 
Upvote 0
If there is no blank between the columns, that is each row contains no blank from first occourrance of data to the last then this should work, just adjust the range to your need.


Excel Workbook
ABCDEFG
12410020022510003000
2406050008000
3304404003002000
4Result
54225
613000
72700
8
Sheet5
 
Upvote 0
This is really close...thanks for taking a stab. The formula actually should only account for 52 columns if the cells meet the critiera >200, as in your example. My report has a total of 199 data columns so somehow, the formula should stop summing at 52 columns or when there is blank data. It appears that the formula you posted accounts for all cells that are not blank and above 200 -- am I reading that right?
 
Upvote 0
A quick fix will be to adjust the range to match.

Instead of this :

=SUMIF(OFFSET(A1,,,,COUNTA(1:1)+SUMPRODUCT(--ISBLANK(A1:G1))),">200")

change it to :


=SUMIF(OFFSET(A1,,,,COUNTA(A1:AZ1)+SUMPRODUCT(--ISBLANK(A1:AZ1))),">200")

From A1 to AZ1 there are 52 columns
or
=SUMIF(OFFSET(A1,,,,52),">200")
 
Upvote 0
I should have mentioned that I did adjust my range but the values look as if they are adding everything >200. I know this because I did a manually check.

Since I have 199 columns (C:GS), the start AND end column will vary. I need 52 columns summed together if it is greater than "200" (as in your example). Can we adjust the formula to start counting from when data is greater than 200 and end after 52 columns?
 
Upvote 0
the best i can come up with is this :

=SUM(OFFSET($A1,,MATCH(201,1:1,1)-1,,52))

The match returns the ordinance of which the data range follows with greater than 200, and from there expands to next 52 column.

Hope this help,
 
Upvote 0

Forum statistics

Threads
1,224,564
Messages
6,179,547
Members
452,925
Latest member
duyvmex

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top