+ Reply to Thread
Results 1 to 3 of 3

VBA Loop to check range for Negative number

  1. #1
    Registered User
    Join Date
    06-14-2013
    Location
    Boston
    MS-Off Ver
    Excel 2010
    Posts
    10

    Question VBA Loop to check range for Negative number

    Hello Everyone,

    I have a fairly simple macro that takes a range of numbers and copies them into another workbook for processing. However, I would like to build in a loop to check the range for any negative values and then stop the macro if one is encountered.

    If someone has an idea how to do this either using a loop, or another function, I would appreciate it. The current copy/paste code is below:

    Please Login or Register  to view this content.
    I just need some sort of check on the data in H5:H100 to ensure the values are all positive, and if not, the macro should halt and give an error message to inform the user to verify the data in the range and make corrections before proceeding.

    Thanks for any assistance!
    Zarley
    Last edited by Zarley; 06-14-2013 at 01:58 PM. Reason: Solved

  2. #2
    Forum Contributor Obsessed's Avatar
    Join Date
    05-22-2013
    Location
    Cincinnati, Ohio
    MS-Off Ver
    Excel 365
    Posts
    215

    Re: VBA Loop to check range for Negative number

    Does the data to be processed always fill up exactly H5:H100? If so you could do something like this:

    Please Login or Register  to view this content.
    Last edited by Obsessed; 06-14-2013 at 01:12 PM.

  3. #3
    Registered User
    Join Date
    06-14-2013
    Location
    Boston
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: VBA Loop to check range for Negative number

    That worked perfectly - thank you for the assist!

    Zarley

+ 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