+ Reply to Thread
Results 1 to 8 of 8

Formula similar to if/and/or based on 2 variables

  1. #1
    Registered User
    Join Date
    06-13-2023
    Location
    London
    MS-Off Ver
    365
    Posts
    18

    Formula similar to if/and/or based on 2 variables

    Hi all

    Im getting in a muddle with if/and/or and i cant seem to crack it

    Problem

    2 variables in 2 different cells

    Cell 1

    Can be any number from 1 - 12

    Cell 2 can be any number from 1-12

    i want it so that it only displays the range from the cell input combinations

    eg if i put 3-3 (March to March) it will only show march data, if i put 2-7 (feb to july) it will only show that range data, the other non selecetd months will show blank

    it works if i do 1 to something but then other combos do not work


    Thanks in advanmce
    Attached Files Attached Files

  2. #2
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.84 (24041420))
    Posts
    8,795

    Re: Formula similar to if/and/or based on 2 variables

    how about
    =SUMPRODUCT(($K$2:$V$2>=$F$3)*($K$2:$V$2<=$H$3)*($K$4:$V$19))
    which i have added to F7

    not sure what you want in the row 24

    is it so that adds up each column which matches the range selected

    i'll also do that - but your example shows feb and march totals , when 3 to 3 is selected

    if you just want the column totals for cells matching the selected inputs then

    =IF(AND(K$2>=$F$3,K$2<=$H$3),SUM(K4:K19),"")
    Attached Files Attached Files
    Last edited by etaf; 08-30-2023 at 07:00 AM.
    Wayne
    if my assistance has helped, and only if you wish to , there is an "* Add Reputation" on the left hand side - you can add to my reputation here

    If you have a solution to your thread - Please mark your thread solved do the following: >
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  3. #3
    Registered User
    Join Date
    06-13-2023
    Location
    London
    MS-Off Ver
    365
    Posts
    18

    Re: Formula similar to if/and/or based on 2 variables

    Hi

    Row 24 is where i would like the formula to be written so that it only shows a value if it is within the range of the selected cells

    Otherwise i want it to be blank

    So if i select 4-5 i only wnat columns 4-5 populated the rest should be blank

    I have used the sum function but it could be any function, the key here is that the if statement is triggred if not in the selcted range

    sorry of this does nto make sense

    yes my example shows me not succeeding as when i put 4-4 in all should be blank

  4. #4
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.84 (24041420))
    Posts
    8,795

    Re: Formula similar to if/and/or based on 2 variables

    edited and updated my reply as you posted

    see spreadsheet modified using

    =IF(AND(K$2>=$F$3,K$2<=$H$3),SUM(K4:K19),"")

  5. #5
    Registered User
    Join Date
    06-13-2023
    Location
    London
    MS-Off Ver
    365
    Posts
    18

    Re: Formula similar to if/and/or based on 2 variables

    you are a bloody genius

    i dont know why i didint see that..sorry for being a complete nooooob

  6. #6
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.84 (24041420))
    Posts
    8,795

    Re: Formula similar to if/and/or based on 2 variables

    you are welcome, dont apologise , thats why we are here , to help out

  7. #7
    Registered User
    Join Date
    06-13-2023
    Location
    London
    MS-Off Ver
    365
    Posts
    18

    Re: Formula similar to if/and/or based on 2 variables

    seriously this is sooooo good it works so sweetly!!!! i can use it with any function now like an index ...thanks again

  8. #8
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.84 (24041420))
    Posts
    8,795

    Re: Formula similar to if/and/or based on 2 variables

    you are welcome

+ 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. Formula to sum values of variables based on similarity
    By ahmadjumaa80 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 07-17-2022, 04:47 PM
  2. [SOLVED] Formula based on several variables
    By msk8tlyn in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 03-02-2021, 12:22 PM
  3. Formula to add, based on number variables
    By Reol in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 03-01-2017, 08:08 AM
  4. Formula to combine text based on variables
    By billyshears in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-08-2016, 04:28 PM
  5. Formula to Return a Value based on 2 Variables
    By Howdoesitwork in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 01-30-2015, 12:42 PM
  6. Output strings of texts and variables, using Selection TypeText or similar function?
    By excelicus in forum Word Programming / VBA / Macros
    Replies: 11
    Last Post: 12-26-2014, 11:17 PM
  7. [SOLVED] Formula based on multiple variables
    By Jmoney in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-30-2013, 10:32 AM

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