+ Reply to Thread
Results 1 to 12 of 12

Error check and if the cell is not numeric or empty loop to the next item

  1. #1
    Registered User
    Join Date
    05-31-2013
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    83

    Error check and if the cell is not numeric or empty loop to the next item

    I have a loop set up to run a function. I need to be able to do some validation and if a cell is invalid it skips to the next loop. I have numerous error checks to do and should any of them be an error I want to skip to the next loop. I know its easy I just cant picture it

    Thanks

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Error check and if the cell is not numeric or empty loop to the next item

    Hi,

    Well at its simplest you need to preface the loop..end loop instruction with an IF test on the cell which might be invalid. If the test is succesful then the loop will run, if not control will bypass the loop to the End If statement.

    In order to advise more I think we need to see the workbook.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Error check and if the cell is not numeric or empty loop to the next item

    can't you just perform each test and only run the code if all pass?
    Please Login or Register  to view this content.
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  4. #4
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Error check and if the cell is not numeric or empty loop to the next item

    Something like this:
    Please Login or Register  to view this content.
    I could make it more precise if you wanted to attach your workbook.
    Last edited by Solus Rankin; 07-23-2013 at 09:25 AM.
    Thanks,
    Solus


    Please remember the following:

    1. Use [code] code tags [/code]. It keeps posts clean, easy-to-read, and maintains VBA formatting.
    Highlight the code in your post and press the # button in the toolbar.
    2. Show appreciation to those who have helped you by clicking below their posts.
    3. If you are happy with a solution to your problem, mark the thread as [SOLVED] using the tools at the top.

    "Slow is smooth, smooth is fast."

  5. #5
    Registered User
    Join Date
    05-31-2013
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    83

    Re: Error check and if the cell is not numeric or empty loop to the next item

    This is what I have:

    Please Login or Register  to view this content.

    What I want to do is ensure these cell are valid if they are run the function on that row, if their not skip to the next row

  6. #6
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Error check and if the cell is not numeric or empty loop to the next item

    perhaps
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    05-31-2013
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    83

    Re: Error check and if the cell is not numeric or empty loop to the next item

    Hi Josie,

    ive tried this but it doesn't work, if a letter is typed there is a miss match, and if a row is empty it doesn't complete the function

    I don't fully understand how it works so couldn't try to alter it, if you could an explanation would be helpful

    Thanks

  8. #8
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Error check and if the cell is not numeric or empty loop to the next item

    my bad-had the resize method wrong
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    05-31-2013
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    83

    Re: Error check and if the cell is not numeric or empty loop to the next item

    Excellent thanks Josie that works

    but what is this magic you have used ive never come across error handling like that and I could use it in a load of places.

    Regards

    Jim

  10. #10
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Error check and if the cell is not numeric or empty loop to the next item

    that ain't magic ;-)

    it just uses the COUNT worksheet function to make sure there are 4 numbers in the 4 cells and the COUNTIF function to make sure all 4 are greater than 0

  11. #11
    Registered User
    Join Date
    05-31-2013
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    83

    Re: Error check and if the cell is not numeric or empty loop to the next item

    Ah that makes sense I like the use of resize I shall certainly be using that one in the future

    Thanks for your help

  12. #12
    Registered User
    Join Date
    05-31-2013
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    83

    Re: Error check and if the cell is not numeric or empty loop to the next item

    Ah that makes sense I like the use of resize I shall certainly be using that one in the future

    Thanks for your help

+ 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. [SOLVED] How to write loop to check for empty cells
    By JaydenK in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-22-2013, 09:17 AM
  2. [SOLVED] Makro with if condition to check for numeric and text values in a cell range
    By Postlki1 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-14-2013, 07:53 AM
  3. [SOLVED] Loop Until Empty Cell
    By gtiguy in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-19-2012, 09:20 PM
  4. [SOLVED] Match Formula to Check if Cell Value is Within a Numeric Range Table
    By dieseldogpi in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-16-2012, 12:04 PM
  5. Do Loop for Error check
    By Stephen in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-20-2006, 08:30 AM

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