+ Reply to Thread
Results 1 to 7 of 7

Sum based on Variable end text

  1. #1
    Forum Contributor
    Join Date
    06-04-2013
    Location
    Suffolk, England
    MS-Off Ver
    Office 365
    Posts
    220

    Sum based on Variable end text

    Morning,

    I am looking for a formula that can extend based on a cell value.

    I have a table from P1 > P12 and i need it to sum from P1 to value in U2 (P11)

    I have attached a test sheet.

    As always, any help is greatly appreciated!

    Regards
    Ross
    Attached Files Attached Files

  2. #2
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,166

    Re: Sum based on Variable end text

    Try this:

    =SUM(OFFSET($B$1,1,1,,MATCH(LOOKUP($U1,$R$2:$R$25,Q$2:Q$25),$B$1:$M$1,0)-1))
    Never use Merged Cells in Excel

  3. #3
    Forum Expert
    Join Date
    01-05-2013
    Location
    Singapore
    MS-Off Ver
    H&B2019
    Posts
    4,542

    Re: Sum based on Variable end text

    Try, =SUM(TAKE(B2:M2,,MATCH(U2,B1:M1,0)))

  4. #4
    Forum Expert
    Join Date
    01-05-2013
    Location
    Singapore
    MS-Off Ver
    H&B2019
    Posts
    4,542

    Re: Sum based on Variable end text

    Are your financial period end dates always the last Sundays of the month?

    If yes, then you could apply this formula in cell S3 and copy down: =EOMONTH(S2,1)-WEEKDAY(EOMONTH(S2,1),2)+IF(WEEKDAY(EOMONTH(S2,1),2)=7,7,0)
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    06-04-2013
    Location
    Suffolk, England
    MS-Off Ver
    Office 365
    Posts
    220

    Re: Sum based on Variable end text

    Quote Originally Posted by zbor View Post
    Try this:

    =SUM(OFFSET($B$1,1,1,,MATCH(LOOKUP($U1,$R$2:$R$25,Q$2:Q$25),$B$1:$M$1,0)-1))
    Cheers zbor - tried this but only ended up with 500 - not 550 as expected?

    Quote Originally Posted by josephteh View Post
    Try, =SUM(TAKE(B2:M2,,MATCH(U2,B1:M1,0)))
    This works great thanks Joseph

    Quote Originally Posted by josephteh View Post
    Are your financial period end dates always the last Sundays of the month?

    If yes, then you could apply this formula in cell S3 and copy down: =EOMONTH(S2,1)-WEEKDAY(EOMONTH(S2,1),2)+IF(WEEKDAY(EOMONTH(S2,1),2)=7,7,0)
    Sort of, but works on a 5/4/4 basis.... you other answer works perfect so no worries on this one.


    Thank you all for your help!!

  6. #6
    Forum Expert
    Join Date
    01-05-2013
    Location
    Singapore
    MS-Off Ver
    H&B2019
    Posts
    4,542

    Re: Sum based on Variable end text

    You are welcome and thanks for the Rep. You could use these formulas for Start Date and End Date:

    End Date in $S$2: =R2+IF(MOD(MID(Q2,2,2),3)=1,5,4)*7-1
    Start Date in $R$3: =S2+1
    Attached Files Attached Files

  7. #7
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    49,655

    Re: Sum based on Variable end text

    One way:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. XLOOKUP Does Not Work With Text-based As Lookup Variable
    By SweetBaboo in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-26-2022, 01:56 PM
  2. [SOLVED] Put text into cell based on variable name - why not?
    By OpieWinston in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-15-2021, 10:02 AM
  3. Connection Commnd text / variable based on lookup table
    By Jabba69 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-07-2018, 05:57 AM
  4. How to predefine UserForm text boxes based off a variable?
    By AnthonyGFS in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-11-2017, 02:50 AM
  5. [SOLVED] Excel 2007 : Moving a Range Based on Variable Text Value
    By KSSLR in forum Excel General
    Replies: 8
    Last Post: 06-12-2012, 02:53 PM
  6. [SOLVED] Change calculation based on variable text in different cell
    By tradersteve in forum Excel General
    Replies: 2
    Last Post: 10-09-2010, 10:03 PM
  7. [SOLVED] Set variable sort range based on found text
    By jeffbert in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-20-2006, 05:20 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1