Solved

is there a better formula

Posted on 2015-01-23
7
108 Views
Last Modified: 2015-01-23
the below formula is in a spreadsheet I am working on. Is there a better and shorter way to say this

=IF(MonthlyQuarterly!$S$1=MonthlyQuarterly!AF$3
SUM(MonthlyQuarterly!AF$4:AF$32)
IF(MonthlyQuarterly!$S$1=MonthlyQuarterly!AG$3
SUM(MonthlyQuarterly!AG$4:AG$32)
IF(MonthlyQuarterly!$S$1=MonthlyQuarterly!AH$3
SUM(MonthlyQuarterly!AH$4:AH$32)
IF(MonthlyQuarterly!$S$1=MonthlyQuarterly!AI$3
SUM(MonthlyQuarterly!AI$4:AI$32)
IF(MonthlyQuarterly!$S$1=MonthlyQuarterly!AJ$3
SUM(MonthlyQuarterly!AJ$4:AJ$32)
IF(MonthlyQuarterly!$S$1=MonthlyQuarterly!AK$3
SUM(MonthlyQuarterly!AK$4:AK$32)
IF(MonthlyQuarterly!$S$1=MonthlyQuarterly!AL$3
SUM(MonthlyQuarterly!AL$4:AL$32)
IF(MonthlyQuarterly!$S$1=MonthlyQuarterly!AM$3
SUM(MonthlyQuarterly!AM$4:AM$32)
IF(MonthlyQuarterly!$S$1=MonthlyQuarterly!AN$3
SUM(MonthlyQuarterly!AN$4:AN$32)
IF(MonthlyQuarterly!$S$1=MonthlyQuarterly!AO$3
SUM(MonthlyQuarterly!AO$4:AO$32)
IF(MonthlyQuarterly!$S$1=MonthlyQuarterly!AP$3
SUM(MonthlyQuarterly!AP$4:AP$32)
IF(MonthlyQuarterly!$S$1=MonthlyQuarterly!AQ$3
SUM(MonthlyQuarterly!AQ$4:AQ$32)
0))))))))))))
0
Comment
Question by:Jagwarman
  • 4
  • 2
7 Comments
 
LVL 32

Expert Comment

by:Rob Henson
ID: 40566203
I suspect you can use the OFFSET function with that, give me a few minutes and I will formulate.
0
 
LVL 24

Accepted Solution

by:
Phillip Burton earned 250 total points
ID: 40566209
If you have in AF2

=SUM(AF4:AF32)

and copy that across to AQ2, then you can have

=SUMIF(MonthlyQuarterly!AF3:AQ3,MonthlyQuarterly!$S$1,MonthlyQuarterly!AF2:AQ2)
0
 
LVL 32

Expert Comment

by:Rob Henson
ID: 40566213
=SUM(OFFSET(MonthlyQuarterly!$AE$4,0,MATCH(MonthlyQuarterly!$S$1,MonthlyQuarterly!$AF$3:$AQ$3,0),29,1))

This works for the existing range, if the data extends beyond row 32 then you will have to adjust the 29 accordingly. Alternatively if there is no data below the range being summed until it expands downwards, adjust the 29 to a number that is more than adequate to cover future expansion.

Thanks
Rob H
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 32

Expert Comment

by:Rob Henson
ID: 40566250
I have made a couple of assumptions in the answer. Values in S1 and range AF3:AQ3 are dates and they are true numerical dates rather than text. Assumption based on the sheet being called "MonthlyQuarterly" and there being 12 columns to which the formula is referring.

If that is in fact an incorrect assumption and the header and comparison values are text, you can use the following DSUM formula:

=DSUM(MonthlyQuarterly!$AF$3:$AQ$32,MonthlyQuarterly!$S$1,MonthlyQuarterly!$S$1:$S$2)

The only addition to the known cell references which you have given would be the entry of "<>0" in cell S2, or just making sure it is blank would work.

In addition, if this formula is going on the "MonthlyQuarterly" sheet, you don't need the sheet references in the formula.

If you need explanation of either the DSUM or OFFSET functions, please let me know.

Thanks
Rob H
0
 

Author Comment

by:Jagwarman
ID: 40566394
Rob

the formula =DSUM(MonthlyQuarterly!$AF$3:$AQ$32,MonthlyQuarterly!$S$1,MonthlyQuarterly!$S$1:$S$2)

Returns #VALUE

the formula =SUM(OFFSET(MonthlyQuarterly!$AE$4,0,MATCH(MonthlyQuarterly!$S$1,MonthlyQuarterly!$AF$3:$AQ$3,0),29,1))

Returns #N/A
0
 
LVL 32

Assisted Solution

by:Rob Henson
Rob Henson earned 250 total points
ID: 40566422
DSUM will only work if the date values are text, it won't work with true dates.

The only way that I can think that the SUM(OFFSET()) would generate an #N/A error is if the value in S1 cannot be matched in the row of values AF3:AQ3. I assumed that the dates would be an exact match. To check copy this part of the formula into a separate cell and see what result it gives:

=MATCH(MonthlyQuarterly!$S$1,MonthlyQuarterly!$AF$3:$AQ$3,0)

See attached with both examples.

Thanks
Rob H
DSUM-and-SUM-OFFSET.xlsx
0
 

Author Closing Comment

by:Jagwarman
ID: 40566542
Thanks for the assistance
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sparklines have been introduced with Excel 2010 and are a useful tool for creating small in-cell charts, used for example in dashboards. Excel 2010 offers three different types of Sparklines: Line, Column and Win/Loss. What it does not offer is a…
Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now