+ Reply to Thread
Results 1 to 6 of 6

Checking 3+ ranges to qualify a value

  1. #1
    Registered User
    Join Date
    02-24-2011
    Location
    Toronto
    MS-Off Ver
    Excel 2007
    Posts
    8

    Checking 3+ ranges to qualify a value

    So I am not very familiar with VBA but I want to practice more with it so I created a little project to try and was wondering if anyone could give me a push in the right direction.

    What I want to do: I want to check 3 or more ranges of cells ie.. b1:k1, a2:a27, b2:g9 to see if the number I am looking for is present say 1928.
    If 1928 appears in any of the cells in the above ranges I want to set a different cell, say a1, as blank, if it is not then I want to set a1 as 1928.

    Any suggestions?

  2. #2
    Forum Expert Simon Lloyd's Avatar
    Join Date
    03-02-2004
    Location
    locked in the cage
    MS-Off Ver
    All the ones my homepage shows
    Posts
    3,161

    Re: Checking 3+ ranges to qualify a value

    Use CountIfs, the syntax looks like this =COUNTIFS( Criteria_range-1, Criteria-1, Criteria_range-2, Criteria-2, ...) so in your case put this in A1:
    =IF(COUNTIFS( b1:k1, 1928, a2:a27, 1928, b2:g9, 1928)>=1,"",1)
    Not all forums are the same - seek and you shall find

  3. #3
    Registered User
    Join Date
    02-24-2011
    Location
    Toronto
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Checking 3+ ranges to qualify a value

    Quote Originally Posted by Simon Lloyd View Post
    Use CountIfs, the syntax looks like this =COUNTIFS( Criteria_range-1, Criteria-1, Criteria_range-2, Criteria-2, ...) so in your case put this in A1:
    =IF(COUNTIFS( b1:k1, 1928, a2:a27, 1928, b2:g9, 1928)>=1,"",1)
    I tried this out and it works great with one range. If I add a second range it just returns #value or for some odd reason in the cell I originally wanted the formula it returns the value 8 and replaces the formula. Very strange.

  4. #4
    Forum Expert Simon Lloyd's Avatar
    Join Date
    03-02-2004
    Location
    locked in the cage
    MS-Off Ver
    All the ones my homepage shows
    Posts
    3,161

    Re: Checking 3+ ranges to qualify a value

    What do you mean one range?, there's 3 ranges in that formula, can you supply a sample workbook where you have used this? Did you use my formula starting with =IF ?

  5. #5
    Registered User
    Join Date
    02-24-2011
    Location
    Toronto
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Checking 3+ ranges to qualify a value

    Hi Simon,
    sorry about the long delay in responding but got a little busy at work here.

    What I meant is that when I used the formula (exactly as you posted it) and with the 3 ranges included it returned #VALUE!.
    With only one range used it works fine. I may just have to use 2 embedded ifs to get the result I need.

  6. #6
    Forum Expert Simon Lloyd's Avatar
    Join Date
    03-02-2004
    Location
    locked in the cage
    MS-Off Ver
    All the ones my homepage shows
    Posts
    3,161

    Re: Checking 3+ ranges to qualify a value

    If it showed #VALUE there must be something wrong with your data set or range, can you post a sample workbook with similar data in similar ranges so we can provide the answer you need?

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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