+ Reply to Thread
Results 1 to 26 of 26

If Formula

  1. #1
    Registered User
    Join Date
    08-14-2014
    Location
    London
    MS-Off Ver
    2010
    Posts
    19

    If Formula

    I'm trying to construct a formula which which looks at a column of data and checks if a number of answers are found. Because this is a weekly report, the number of entries in this column will differ and so I need to look up the whole column. Also, both the column data and the references will be on two different tabs. I hope this is clear enough to help me!

  2. #2
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: If Formula

    I think we're going to need some more specific details.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  3. #3
    Registered User
    Join Date
    08-14-2014
    Location
    London
    MS-Off Ver
    2010
    Posts
    19

    Re: If Formula

    OK, I have knocked up a dummy spreadsheet, see attached.
    I want the formula in C3, in Result Tab, to check column A in the Check Tab for the locations highlighted in red in the Reference Tab.
    If there are any of these locations found, then the result should be 'BREACH', if none are found, then the result should be 'OK'.
    I have already conditionally formatted cell C3 in Result as per the screenshot on the tab.
    Cheers.

  4. #4
    Registered User
    Join Date
    08-14-2014
    Location
    London
    MS-Off Ver
    2010
    Posts
    19

    Re: If Formula

    The attachment may help....
    Attached Files Attached Files

  5. #5
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,064

    Re: If Formula

    The codes in red on the reference tab do not have Conditional Formatting rules attached.
    You can only detect the colour of a cell using VBA.
    You're gonna need VBA to detect those red cells unless you can set them with Conditional Formatting.
    Regards
    Special-K

    Ensure you describe your problem clearly, I have little time available to solve these problems and do not appreciate numerous changes to them.

  6. #6
    Registered User
    Join Date
    08-14-2014
    Location
    London
    MS-Off Ver
    2010
    Posts
    19

    Re: If Formula

    The colour of the cells in the reference tab are only there as a guide as to which ones are ineligible, not to necessarily be used within the formula. Surely the cell references can be used to check?

  7. #7
    Registered User
    Join Date
    08-14-2014
    Location
    London
    MS-Off Ver
    2010
    Posts
    19

    Re: If Formula

    Hi, can anyone help with this?

  8. #8
    Forum Expert
    Join Date
    03-28-2014
    Location
    Hyderabad,India
    MS-Off Ver
    Excel 2013
    Posts
    1,887

    Re: If Formula

    Hi,

    Try this
    With A helper Column & Name Manager
    Punnam
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    08-14-2014
    Location
    London
    MS-Off Ver
    2010
    Posts
    19

    Re: If Formula

    Thanks, that works nearly perfeclty. The only problem is, is that because the real data that is going to be copied into he 'Check' tab is quite large and so I dont want to be adding in another column to include a Countif formula. Plus, as it may not just be me running this report, I want to make it fool proof and so it just checks the column for the particular codes and returns the answer. Can this be done? Thanks.

  10. #10
    Forum Expert
    Join Date
    03-28-2014
    Location
    Hyderabad,India
    MS-Off Ver
    Excel 2013
    Posts
    1,887

    Re: If Formula

    I tried but unable to get one , wait for more solutions

    Punnam

  11. #11
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: If Formula

    Try this...

    On the Reference sheet, in column B enter a X in the cells that you want to check:

    Data Range
    A
    B
    2
    Eligeble
    Check = X
    3
    DUN
    4
    FON
    5
    OWF
    6
    OWD
    7
    SHP
    8
    DEP
    9
    SHPF2
    X
    10
    SHPF4
    X
    11
    SHPF5
    12
    ONT
    13
    OWC
    X
    14
    OWB
    X
    15
    OWG
    X
    16
    OWCF2
    X
    17
    OWBF2
    X
    18
    OWGF2
    X
    19
    OWCF4
    X
    20
    OWBF4
    X
    21
    OWGF4
    X
    22
    BAL
    X
    23
    CIS
    X
    24
    NBR
    X
    25
    DSP
    X


    Then, on the Result sheet enter this array formula** in C3:

    =IF(SUM(--ISNUMBER(MATCH(Check!A2:A10000,IF(Reference!B3:B25="x",Reference!A3:A25),0)))>0,"Breach","OK")

    ** array formulas need to be entered using the key
    combination of CTRL,SHIFT,ENTER (not just ENTER).
    Hold down both the CTRL key and the SHIFT key
    then hit ENTER.

  12. #12
    Registered User
    Join Date
    08-14-2014
    Location
    London
    MS-Off Ver
    2010
    Posts
    19

    Re: If Formula

    Hi, thanks for this. It worked perfectly in my test report, but as soon as I tried transferring it into my real report (obviously changing the sheet names and cell reference etc), it wouldn't work.
    The data that I am using as my check is grouped, would this make any difference to how this formula works?

  13. #13
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: If Formula

    Quote Originally Posted by Russ76 View Post
    The data that I am using as my check is grouped, would this make any difference to how this formula works?
    Shouldn't, no.

  14. #14
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: If Formula

    I can post a copy of the sample file you attached where the formula does what you asked for but I'm assuming that's the same file you tested the formula in?

    I have a "thing" about downloading big files. I usually don't do it if the file is >50kb but I made an exception for your file (70kb).

    I'm guessing that your real file is much bigger than 70kb in which case I don't want to download it!

    Maybe someone else will be willing to look at the real file.

  15. #15
    Registered User
    Join Date
    08-14-2014
    Location
    London
    MS-Off Ver
    2010
    Posts
    19

    Re: If Formula

    Hi Tony,

    the real life file is much bigger but also it is a work report and so contains sensitive info, and so I can't/won't upload it.
    It's really frustrating, as the solution that was offered worked really well in the test but for some reason won't in the real life report. I'll keep on working through it though as it might just be a glitch.

  16. #16
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: If Formula

    When you said it wouldn't work can you be more specific?

    Did you get an incorrect result? An error? Something else?

  17. #17
    Registered User
    Join Date
    08-14-2014
    Location
    London
    MS-Off Ver
    2010
    Posts
    19

    Re: If Formula

    Hi, I managed to get the formula working. It seems I was being an idiot and not entering the formula correctly ie Ctrl,Shift,Enter.
    I'm now trying to get a Countifs formula working which would count all of the values in green from the 'reference' tab which are found in the 'check' tab.
    I've played around a bit trying to get this to work but I keep on receiving a 'zero' result. Any offers?
    Cheers, again!

  18. #18
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: If Formula

    If you put the criteria in a contiguous range like Reference!A3:A10...

    Then, this formula entered on the Result sheet:

    =SUMPRODUCT(COUNTIF(Check!A:A,Reference!A3:A10))

  19. #19
    Registered User
    Join Date
    08-14-2014
    Location
    London
    MS-Off Ver
    2010
    Posts
    19

    Re: If Formula

    Hi, thanks Tony. I tried that formula but it only pulled through 3174 as a result when the figure should be 5701. I copy and paste your formula and so is there something I am not doing?

  20. #20
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: If Formula

    Based on the sample file in post #4 I also get a result of 3174.

    This can be verified by using intermediate formulas and then getting the sum of the intermediate formulas.

    On the Reference sheet:

    Data Range
    A
    B
    C
    D
    E
    1
    ------
    ------
    ------
    ------
    2
    Eligeble
    Total
    3
    DUN
    844
    3174
    =SUM(B3:B10)
    4
    FON
    515
    5
    OWF
    258
    3174
    =SUMPRODUCT(COUNTIF(Check!A:A,Reference!A3:A10))
    6
    OWD
    532
    7
    SHP
    895
    8
    DEP
    0
    9
    SHPF5
    0
    10
    ONT
    130


    This formula entered in B3 and copied down to B10:

    =COUNTIF(Check!A:A,A3)

    The results of both formulas are the same.

    It's quite a difference from 3174 and 5701. Maybe I didn't understand what needs to be counted?

  21. #21
    Registered User
    Join Date
    08-14-2014
    Location
    London
    MS-Off Ver
    2010
    Posts
    19

    Re: If Formula

    For some reason, its not pulling through the figures for 'DEP'. In your table you have a figure of zero but I have done a manual check and found that there is 2527, which combined with the above equals 5701.

  22. #22
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: If Formula

    OK, found the problem.

    In the sample file on the Reference sheet, cell A8 contains DEP but there's a trailing space character: DEP_.

    Remove that space character and you'll get:

    Data Range
    A
    B
    C
    D
    E
    1
    ------
    ------
    ------
    ------
    2
    Eligeble
    Total
    3
    DUN
    844
    5701
    =SUM(B3:B10)
    4
    FON
    515
    5
    OWF
    258
    5701
    =SUMPRODUCT(COUNTIF(Check!A:A,Reference!A3:A10))
    6
    OWD
    532
    7
    SHP
    895
    8
    DEP
    2527
    9
    SHPF5
    0
    10
    ONT
    130

  23. #23
    Registered User
    Join Date
    08-15-2014
    Location
    India
    MS-Off Ver
    2007
    Posts
    57

    Re: If Formula

    Hey,

    I hope you have changed the Cell Range also.

    Reg,
    CVishu

  24. #24
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: If Formula

    Quote Originally Posted by cvishu View Post

    I hope you have changed the Cell Range also.
    Which cell range?

  25. #25
    Registered User
    Join Date
    08-15-2014
    Location
    India
    MS-Off Ver
    2007
    Posts
    57

    Re: If Formula

    the cell range is given as A3:A10 is that the whole range for your data

  26. #26
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: If Formula

    That's just the criteria range. The data range is Check!A:A.

+ 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. Replies: 11
    Last Post: 06-06-2014, 03:34 PM
  2. how to hide formula in formula box, view lookup result in formula box?
    By vengatvj in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-14-2013, 04:06 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