+ Reply to Thread
Results 1 to 24 of 24

If Range =

  1. #1
    Registered User
    Join Date
    09-22-2015
    Location
    Work
    MS-Off Ver
    2010
    Posts
    14

    If Range =

    Hi All,

    I'm fairly new to this so getting my head around the way excel works has been a steep learning curve, but I'm getting there!

    Anyway, my question... what I am trying to do is create something which I thought would be quite simple.

    So logically... =IF(R1:R20=1, "Error", "")

    Apparently excel doesn't work this way because it doesn't work... what am I doing wrong?

    Thanks
    Alex

  2. #2
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,501

    Re: If Range =

    so you are looking to see if 1 is in that range? try =if(COUNTIF(R1:R20)>0,"Error","")

    EDIT, sorry, try it this way... =if(COUNTIF(R1:R20,">"&0)>0,"Error","")
    Last edited by Sam Capricci; 09-22-2015 at 04:58 AM.
    Make contributors happy, click on the "* Add Reputation" as a way to say thank you.
    Sam Capricci

  3. #3
    Valued Forum Contributor mangesh.mehendale's Avatar
    Join Date
    06-04-2015
    Location
    India
    MS-Off Ver
    2007
    Posts
    510

    Re: If Range =

    Excel don`t understand the meaning of only Range R1:R20..... You should have to specify like sum(R1:20) or count(R1:R20)....
    Don`t care, take care...

    Regards,
    Mangesh

  4. #4
    Registered User
    Join Date
    09-22-2015
    Location
    Work
    MS-Off Ver
    2010
    Posts
    14

    Re: If Range =

    Thanks guys, this works! Much appreciated... slowly getting my head around how this works

    I understand how it works in theory, but what I dont get is this little bit in red below... why does it need an &?

    =if(COUNTIF(R1:R20,">"&0)>0,"Error","")

  5. #5
    Registered User
    Join Date
    09-22-2015
    Location
    Work
    MS-Off Ver
    2010
    Posts
    14

    Re: If Range =

    Why not just

    =IF(COUNTIF(R1:R20, ">0","Error","Fleet Code - Enquiry")

  6. #6
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,501

    Re: If Range =

    These people explain it better than I can.
    it has to do with creating a text string...
    http://www.excelforum.com/excel-gene...t-formula.html

  7. #7
    Registered User
    Join Date
    09-22-2015
    Location
    Work
    MS-Off Ver
    2010
    Posts
    14

    Re: If Range =

    Fantastic, Ill give it a read!

    Really appreciate both of yours help.

  8. #8
    Registered User
    Join Date
    09-22-2015
    Location
    Work
    MS-Off Ver
    2010
    Posts
    14

    Re: If Range =

    Ok, along the same line...

    IF Range = 1 then Error 1, if Range = 2 then error 2 ... etc...

    ?

  9. #9
    Forum Expert Debraj Roy's Avatar
    Join Date
    09-27-2012
    Location
    New Delhi,India
    MS-Off Ver
    Excel 2013
    Posts
    1,469

    Re: If Range =

    Hi Alex,

    Do you want to check "If nay value is 1 or 2 or..." or you want to check.. "If all values are 1 or 2 or..."
    Regards!
    =DEC2HEX(3563)

    If you like someone's answer, click the star to give them a reputation point for that answer...

  10. #10
    Registered User
    Join Date
    09-22-2015
    Location
    Work
    MS-Off Ver
    2010
    Posts
    14

    Re: If Range =

    Hi Debraj,

    Basically what I want is, if the number 10 appears anywhere in column R then cell A1 to say "error". If the number 5 appears, then A1 say "error", if the number 2 appears then say "error"... if nothing appears then ""

    Does that make sense?

  11. #11
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,501

    Re: If Range =

    The formula I wrote says that if any value greater than 0 appears in that range note as error. Doesn't that satisfy your post #10?

  12. #12
    Registered User
    Join Date
    09-22-2015
    Location
    Work
    MS-Off Ver
    2010
    Posts
    14

    Re: If Range =

    Hi Sambo Kid, not quite... only because I realise I need to use multiple error codes for different errors ... anything greater than 0 gives me just 1 error.

    So if my range pops up the number 10 ... I know that I have a date mismatch ... the number 5 a name mismatch etc...

  13. #13
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,501

    Re: If Range =

    do you still need this to be a range then? Let's say that cell R1 has a 1 but R2 has a 10 and R13 has a 5?
    then what would your results be for a range of R1:R20?
    maybe it should be individually by cell instead of a range?

  14. #14
    Registered User
    Join Date
    09-22-2015
    Location
    Work
    MS-Off Ver
    2010
    Posts
    14

    Re: If Range =

    Humm I see your point... would be 10 times easier to code as well. Ill give it a try and let you know how I get on!

    Thank you!

  15. #15
    Registered User
    Join Date
    09-22-2015
    Location
    Work
    MS-Off Ver
    2010
    Posts
    14

    Re: If Range =

    How about if I wanted.

    If (R1:R20 = anything 'ie text' then "Error", "")

  16. #16
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,501

    Re: If Range =

    do you mean is not null? In other words, any cell within the range of R1:R20 has something in it regardless of what it is?

  17. #17
    Registered User
    Join Date
    09-22-2015
    Location
    Work
    MS-Off Ver
    2010
    Posts
    14

    Re: If Range =

    Yes thats right

  18. #18
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,501

    Re: If Range =

    I worked this one up for your scenario in post # 12...
    '=IF(COUNTIF(R1:R20,"="&1)>0,"Error",IF(COUNTIF(R1:R20,"="&5)>0,"name mismatch",IF(COUNTIF(R1:R20,"="&10)>0,"date mismatch","")))
    but it assumes you don't have a 1 and a 5 or 10 in that range. Maybe you can use it while I try to write another formula for anything within the range.

  19. #19
    Registered User
    Join Date
    09-22-2015
    Location
    Work
    MS-Off Ver
    2010
    Posts
    14

    Re: If Range =

    ok, I managed to get the first line working.. but I need them both to work from the same cell?

    =IF(COUNTIF(R:R,"Dealer Mismatch"),"Error", "")
    =IF(COUNTIF(R:R,"Date Mismatch"),"Error", "")

  20. #20
    Registered User
    Join Date
    09-22-2015
    Location
    Work
    MS-Off Ver
    2010
    Posts
    14

    Re: If Range =

    ooh thank you... Ill check that one out too!

  21. #21
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,501

    Re: If Range =

    so for your post # 17, counting anything within the range that is not blank and returning error =IF(COUNTIF(R1:R20,"<>")>0,"error","") should work for you.

  22. #22
    Registered User
    Join Date
    09-22-2015
    Location
    Work
    MS-Off Ver
    2010
    Posts
    14

    Re: If Range =

    Does this work for text or just numeric?

  23. #23
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,501

    Re: If Range =

    what I gave you in post #21 will work for anything that appears in that range which I wrote based on what i asked you in #16 and your answer in #17.

  24. #24
    Registered User
    Join Date
    09-22-2015
    Location
    Work
    MS-Off Ver
    2010
    Posts
    14

    Re: If Range =

    ah gotcha! THank you

+ 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. Loop through each folder copy values from range in file1 to named range in file2
    By dafella in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-16-2015, 05:19 PM
  2. [SOLVED] dynamic named range not populating combo box list if range = single cell
    By HeyInKy in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-24-2014, 05:27 PM
  3. [SOLVED] reference date time range, return the value into all cell that match datetime range
    By Jarvco13 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-22-2013, 10:39 PM
  4. [SOLVED] Count number of occurances below a range, within a range, and below a range
    By maacmaac in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-15-2013, 11:36 PM
  5. send to range, popup box to input what the range should be each time/select range
    By lax2734 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-26-2012, 01:37 AM
  6. [SOLVED] Copy range from multiple sheets, into a master sheet and moving over by variable col range
    By g1eagle in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-23-2012, 01:36 PM
  7. Code to select range and open a user form is opening the wrong range
    By rrbest in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-05-2010, 12:34 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