+ Reply to Thread
Results 1 to 8 of 8

How to check if a number is positve integer in VBA?

  1. #1
    Forum Contributor
    Join Date
    09-10-2016
    Location
    USA
    MS-Off Ver
    Office 365
    Posts
    680

    How to check if a number is positve integer in VBA?

    I use IsNumeric to check if it is a number, then I will need to check if it is positive integer.

    How to check if a number is positive integer or not?

    Thanks.

  2. #2
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: How to check if a number is positve integer in VBA?

    Hi there,

    Enter the following code in a standard VBA CodeModule:

    Please Login or Register  to view this content.

    Use the function by entering "=IsPositiveInteger(B3)" in the required cell, where B3 is the address of the cell whose value you wish to test.


    Hope this helps - please let me know how you get on.

    Regards,

    Greg M

  3. #3
    Forum Contributor
    Join Date
    09-10-2016
    Location
    USA
    MS-Off Ver
    Office 365
    Posts
    680

    Re: How to check if a number is positve integer in VBA?

    Thanks much.

  4. #4
    Valued Forum Contributor
    Join Date
    02-02-2016
    Location
    Indonesia
    MS-Off Ver
    Office 365
    Posts
    1,005

    Re: How to check if a number is positve integer in VBA?

    Just another option:
    Please Login or Register  to view this content.
    Test:
    Please Login or Register  to view this content.

  5. #5
    Valued Forum Contributor
    Join Date
    02-02-2016
    Location
    Indonesia
    MS-Off Ver
    Office 365
    Posts
    1,005

    Re: How to check if a number is positve integer in VBA?

    Sorry, I should add "And x > 0" to the code in post #4:
    Please Login or Register  to view this content.

  6. #6
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    2,032

    Re: How to check if a number is positve integer in VBA?

    One for luck

    Please Login or Register  to view this content.

  7. #7
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,573

    Re: How to check if a number is positve integer in VBA?

    Simply
    Please Login or Register  to view this content.
    Edit
    positive integer
    Exclude 0
    Last edited by jindon; 03-27-2024 at 09:32 AM.

  8. #8
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    2,032

    Re: How to check if a number is positve integer in VBA?

    Even better!

+ 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. Replies: 16
    Last Post: 12-22-2022, 06:04 AM
  2. Check for Integer values in Cells
    By anandrajagopal in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-17-2015, 10:50 AM
  3. Count the number of occurrences of an integer withing a larger integer
    By nnktran in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-26-2010, 01:04 PM
  4. Check that input in textbox is an integer
    By marcusr in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-26-2007, 01:01 PM
  5. [SOLVED] Check if a value is an integer using VBA code
    By Rayo K in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-03-2006, 04:45 PM
  6. [SOLVED] how do I test for Integer?:check out ROUND
    By DerbyJim1978 in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 09-06-2005, 06:05 AM
  7. Check if field is Integer true or false
    By willie64 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-24-2005, 09:11 AM

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