+ Reply to Thread
Results 1 to 8 of 8

Check if any cell in range fulfills required condition

  1. #1
    Forum Contributor vandanavai's Avatar
    Join Date
    09-04-2006
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    256

    Check if any cell in range fulfills required condition

    Hello,

    Please tell me how to go about this. I want 'Message Box' to appear on screen if any cell in selected range fulfills condition specified in macro vb code.

    for example

    If I select Range A1:A10
    If any cell value in this range exceeds 100 then Msgbox "Cell with > 100 value"
    Otherwise no MsgBox.

    Any ideas? Please help.

  2. #2
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Maybe

    If you want it to stop after the first cell find use the exit for statement by removing the '

    Please Login or Register  to view this content.
    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  3. #3
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Why do you need VBA to do this, Conditional Formatting could be used to highlight cells matching the condition & wouldn't need macros enabling.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  4. #4
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Quote Originally Posted by royUK
    Why do you need VBA to do this, Conditional Formatting could be used to highlight cells matching the condition & wouldn't need macros enabling.
    I agree with Roy

    VBA Noob

  5. #5
    Forum Contributor vandanavai's Avatar
    Join Date
    09-04-2006
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    256
    Thanks for help

  6. #6
    Registered User
    Join Date
    04-01-2010
    Location
    New Brunswick, NJ
    MS-Off Ver
    Excel 2007
    Posts
    1

    Re: Check if any cell in range fulfills required condition

    Quote Originally Posted by vandanavai View Post
    Hello,

    Please tell me how to go about this. I want 'Message Box' to appear on screen if any cell in selected range fulfills condition specified in macro vb code.

    for example

    If I select Range A1:A10
    If any cell value in this range exceeds 100 then Msgbox "Cell with > 100 value"
    Otherwise no MsgBox.

    Any ideas? Please help.
    I think if you write the following code in another cell, say A11, it should work. Hope this helps!

    =IF(COUNTIF(A1:A10,">100")>0,"Cell with > 100 value","")


    EDIT: Oops, I just realized I'm 2 years behind. I'm sure you don't need this anymore, but maybe this will help others!

  7. #7
    Registered User
    Join Date
    06-08-2010
    Location
    bangalore
    MS-Off Ver
    Excel 2007
    Posts
    1

    Re: Check if any cell in range fulfills required condition

    Quote Originally Posted by TChang View Post
    I think if you write the following code in another cell, say A11, it should work. Hope this helps!

    =IF(COUNTIF(A1:A10,">100")>0,"Cell with > 100 value","")


    EDIT: Oops, I just realized I'm 2 years behind. I'm sure you don't need this anymore, but maybe this will help others!
    It did help me

    Thanks

  8. #8
    Registered User
    Join Date
    06-02-2010
    Location
    MD- US
    MS-Off Ver
    Excel 2019
    Posts
    42

    Re: Check if any cell in range fulfills required condition

    Me too!
    Thx!

+ 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