Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Junior Member
 
Posts: 3
Default Nesting "indirect" within "sumifs"

I have a very large spreadsheet with muliple named tabs and multiple named ranges within each tab. I will try to be specific but not long winded... The quick explaination is that I am on a construction project that we have to pay an hourly rate to close lanes. The amount we pay per hour depends on time of day, day of the week, number of lanes closed, and section of the road closed. There is a different tab for each section of road. Within each tab are named ranges (one per column in columns B-Z) that uniquely list the fee amounts by day of the week and number of lanes closed. Time is hourly and is in column A on each tab. I want the user to put in basic information have the spreadsheet do the rest of the work. Once the user indicates all variables the spreadsheet should do a sumifs where it sums a certain range (the start time and end time) in the correct named range on the correct tab. The summary tab has the section of road in column U, the named range in column X, the start time in column P and the end time in column R. I think I need to have something along the lines of

=sumifs(indirect("X6"),indirect("U6")&!A4:A99,"=" &P6,indirect("U6")&!A4:A99,"<="&R6)

It appears the error is in the criteria range. I hope this all makes sense... any ideas?
  #2   Report Post  
Junior Member
 
Posts: 3
Default

I have tried editing some syntax to

=SUMIFS(INDIRECT("X6"),indirect("U6")&"!"&A4:A99," ="&P6,indirect("U6")&"!"&A4:A99,"<="&R6)

In the formula wizard it no longer reports any argument as invalid but when I run the function it tells me that there is an error in my formula.
  #3   Report Post  
Junior Member
 
Posts: 2
Thumbs up

Quote:
Originally Posted by Hokie_16 View Post
I have a very large spreadsheet with muliple named tabs and multiple named ranges within each tab.
=sumifs(indirect("X6"),indirect("U6")&!A4:A99,"=" &P6,indirect("U6")&!A4:A99,"<="&R6)

It appears the error is in the criteria range. I hope this all makes sense... any ideas?
There is another function that is easier to use: SUMPRODUCT().

Try this:
=SUMPRODUCT(INDIRECT(X6),(INDIRECT(""&Summary!U6&" !A4:A99")=Summary!P6)*1,(INDIRECT(""&Summary!U6&" !A4:A99")<=Summary!R6)*1)

If X6 contains the name Sec3Monday2, for instance, for Section 2 on Monday with 2 lanes closed, then SUMPRODUCT() will multiply the cost array for that condition by the 0's and 1's created by the time comparisons. You can easily build this up to multiply more than three arrays, so long as all arrays are the same dimension.

For INDIRECT(), you don't need the double quotes.

WPierce
  #4   Report Post  
Junior Member
 
Posts: 2
Smile

Quote:
Originally Posted by Hokie_16 View Post
I have a very large spreadsheet with muliple named tabs ... The summary tab has the section of road in column U, the named range in column X, the start time in column P and the end time in column R. I think I need to have something along the lines of

=sumifs(indirect("X6"),indirect("U6")&!A4:A99,"=" &P6,indirect("U6")&!A4:A99,"<="&R6)

It appears the error is in the criteria range. I hope this all makes sense... any ideas?
Hokie,

The correct use of INDIRECT() would look like this:
=INDIRECT(""&U6&"!A4")=P6

Notice that the contatenated string uses double quotes, but the comparitor does not. Starting with the quotes forces the whole thing to evaluate into a string and allows the "short hand" contatenation.

After sleeping on it, I decided that it shouldn't be that difficult to use SUMIFS() instead of SUMPRODUCT(). So I tried again this morning and received the same answer with both. Yeah!

Be sure to account for equal row numbers when applying SUMIFS(). I entered hours from A2 to A25, so to make SUMIFS() work I used this approach:
=SUMIFS(INDIRECT(X6),INDIRECT(""&U6&"!A2:A25"),"= "&P6,INDIRECT(""&U6&"!A2:A25"),"<="&R6)

You might want to determine whether using < instead of <= would be appropriate; at first glance that would seem to count the fee for the time period following the lane closure.

Regards,
WPierce
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
correct syntax for nesting "if", "and", and "vlookup"....if possib Christine Excel Worksheet Functions 4 January 2nd 09 10:43 PM
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
change "true" and "false" to "availble" and "out of stock" inthestands Excel Worksheet Functions 2 July 19th 07 07:05 PM
HELP on "left","right","find","len","substitute" functions serene83 Excel Discussion (Misc queries) 5 June 27th 06 02:23 AM
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next BCB New Users to Excel 7 May 13th 06 10:02 PM


All times are GMT +1. The time now is 06:00 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"