+ Reply to Thread
Results 1 to 5 of 5

Need help identifying a value range for ending a Loop Until

Hybrid View

  1. #1
    Registered User
    Join Date
    04-30-2013
    Location
    Brussels
    MS-Off Ver
    Excel 2007
    Posts
    35

    Re: Need help identifying a value range for ending a Loop Until

    Dear erik1,

    You can add "OR" and "AND" statements in a Loop Until statement.

    In your case, your code would be:

    Loop Until Range("L433").Value > -0.0055 Or Range("L433").Value < 0.0055
    You can add any criteria (other ranges, other values, variables, any conditions, basically)

    Have fun !
    ExcelTab.com

  2. #2
    Registered User
    Join Date
    06-01-2013
    Location
    boston, ma
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Need help identifying a value range for ending a Loop Until

    Thanks, ExcelTab. I replaced my old Loop Until line with your suggested code and it works, but to get what I specifically was looking for I had to replace your "Or" with an "And." I'm a bit embarrassed because I could've sworn I had tried that already, but there you go. In the meantime I found an alternate fix by using an "IF-AND" [=IF(AND(L433>-0.0055,M433< 0.0055), "Yes","No"] to define a single condition to use as a stop for the macro, but yours of course is the more elegant solution, and I'll switch to that. One additional question: If I wanted to use an "And" along with an "Or" in the same Loop Until, for example--

    Loop Until Range("L433").Value > -0.0055 And Range("L433").Value < 0.0055 Or Range("K433").Value>-0.055 And Range("K433").Value < 0.055

    would I have to use some parentheses or brackets or something around the 2nd half or the statement? Thanks in advance.

  3. #3
    Registered User
    Join Date
    06-01-2013
    Location
    boston, ma
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Need help identifying a value range for ending a Loop Until

    Oops, in the last post I meant:

    "In the meantime I found an alternate fix by using an "IF-AND" [=IF(AND(L433>-0.0055,L433< 0.0055), "Yes","No"] to define a single condition to use as a stop for the macro..."

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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