+ Reply to Thread
Results 1 to 9 of 9

If Then Statement - number above 25 - Excel VBA

  1. #1
    Forum Contributor
    Join Date
    10-25-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    292

    If Then Statement - number above 25 - Excel VBA

    I have written IF Then Statements that said if a specific answer was selected, then take the following steps. But, how would I write an If Then Statement to state if any answer above 25 (so 26, 27, 28, 29, and so on) is given, then take the following steps?

    The answer would always be a number or a range of numbers. Sometimes they will be 21 or another times 22-23, while another time a 27. If the number is above the number 25 then certain steps need to be taken and I want to create an if then statement to cover that.

    Also, I want to create a dialog box that will warn the user they cannot combine 23-24. So, if they enter 23-24, I want a dialog box to pop-up and let them know they cannot use that number combination.

  2. #2
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: If Then Statement - number above 25 - Excel VBA

    Please Login or Register  to view this content.
    Maybe you can use datavalidation for that.

    Excel 2007 => data => datavalition.
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  3. #3
    Forum Contributor
    Join Date
    10-25-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    292

    Re: If Then Statement - number above 25 - Excel VBA

    First I would like to tackle the if then for the answers 26 and above... any ideas on that one?

    I'll have to look into this detavalidation option. Not yet familiar with it. Thank you for bringing it to my attention.

  4. #4
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: If Then Statement - number above 25 - Excel VBA

    answer above 25 (so 26, 27, 28, 29, and so on) Are these names, or do they have cell addresses, if so,you can use the cell reference instead of numbers?

  5. #5
    Forum Contributor
    Join Date
    10-25-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    292

    Re: If Then Statement - number above 25 - Excel VBA

    I'm not following your question. What do you mean by names vs cell addresses. Basically, the user would enter into that text box on the UserForm the answer of a number.

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: If Then Statement - number above 25 - Excel VBA

    Just test the value in the textbox.

    This would work to chec if the value is more than a specific value, but you'll need to explain about the ranges
    and where the 'limit' number comes from.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  7. #7
    Forum Contributor
    Join Date
    10-25-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    292

    Re: If Then Statement - number above 25 - Excel VBA

    Quote Originally Posted by Norie View Post
    Just test the value in the textbox.

    This would work to chec if the value is more than a specific value, but you'll need to explain about the ranges
    and where the 'limit' number comes from.
    Please Login or Register  to view this content.
    To make sure I understand this, the above limit = 26 would mean anything above 25 or above 26?

  8. #8
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: If Then Statement - number above 25 - Excel VBA

    It's anything above 26 in the code I posted but you can change that to whatever you want.

  9. #9
    Forum Contributor
    Join Date
    10-25-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    292

    Re: If Then Statement - number above 25 - Excel VBA

    Thank you!

+ 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