+ Reply to Thread
Results 1 to 10 of 10

Looping Code

  1. #1
    Registered User
    Join Date
    04-05-2007
    Location
    Sydney Australia
    Posts
    48

    Looping Code

    Hi All

    I am using the following code in a project and would like some help to loop it until either TRUE or #N/A is found in the active cell.

    Please Login or Register  to view this content.

    Thanks for any assistance

    Jeff
    Last edited by VBA Noob; 04-28-2007 at 02:42 AM.

  2. #2
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    maxwell13

    Welcome to Excelforum

    Please read the forum rules & wrap your VBA code - see links below
    Please Read Forum Rules Before Posting
    Wrap VBA code by selecting the code and clicking the # icon or Read This
    How To Cross Post politely

    Top Excel links for beginners to Experts

    If you are pleased with a member's answer then use the Scales icon to rate it
    If my reply has assisted or failed to assist you I welcome your Feedback.

  3. #3
    Forum Contributor WinteE's Avatar
    Join Date
    04-07-2007
    Location
    Netherlands
    Posts
    544
    Try something like this,

    Please Login or Register  to view this content.
    Erik

  4. #4
    Registered User
    Join Date
    04-05-2007
    Location
    Sydney Australia
    Posts
    48
    Hi mudraker thanks for the welcome and sorry for not wrapping my code.

    Thanks for your reply Erik but i really don't understand what you have posted.
    I would like my code to keep repeating itself until a value other than False is found in the active cell. The data in the active cell is the result of an OR function formula returning either False, True or #N/A

    Thanks

    Jeff

  5. #5
    Forum Contributor WinteE's Avatar
    Join Date
    04-07-2007
    Location
    Netherlands
    Posts
    544
    You have to put this code into a macro like

    Please Login or Register  to view this content.

    Where the range contains all field you want to search in. The For Each .. Next will search all field in the range.

    Erik

  6. #6
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    jeff

    Thanks for wrapping your code.

    I am not sure I fully understand what you require but try this


    Please Login or Register  to view this content.
    When testing an item like a cell value for multiple results Select Case statements are more efficient than If statements

    You can also with with cell values etc without selecting them

  7. #7
    Registered User
    Join Date
    04-05-2007
    Location
    Sydney Australia
    Posts
    48

    Red face

    Hi mudraker

    Thanks for your time and response to my post. I have used your code with a slight edit (changed "False" to "True" )and found it works great except if the value in the selected cell is N/A. If this occurs I get an error and the code stops.


    Please Login or Register  to view this content.
    Basically I would like the code to keep repeating until the value in the selected cell is not equal to "False".

    I tried the following but get this

    Compile Error Expected: expression

    Please Login or Register  to view this content.
    Any further guidance greatly appreciated

    Thanks

    Jeff

    Off topic: What about Gilly!!!

  8. #8
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    As you are only interested if the value is not false we can go back to using If statements

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    04-05-2007
    Location
    Sydney Australia
    Posts
    48

    Thumbs up

    Thanks for all your help mudraker i have finally got it working.

    Ended up using IFNA function to replace the N/A with a zero and then went back to using your Select Case statement.

    It works exactly as I wanted!!!

    Thanks again

    Jeff

  10. #10
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    good to hear you resolved the problem

+ 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