Results 1 to 4 of 4

Thread: Restrict InputBox to Numbers

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #3
    Or this:
    Dim counter As Integer
    Dim Pages As Integer
    Dim NoOfPages As String
    NoOfPages = InputBox(Prompt:="Enter the number of additional pages you need", _
          Title:="No. of additional pages", Default:="Enter number here")
    If Not IsNumeric(NoOfPages) Then
       MsgBox "You can only enter a number in this field"
       Else
       Pages = Val(NoOfPages)
       If Pages < 1 Or Pages > 5 Then
          MsgBox "Pages must be between 1 and 5!"
          Else
          For counter = 1 To Pages
             ' Do stuff
          Next
       End If
    End If
    Regards
    Last edited by Aussiebear; 03-30-2023 at 02:22 PM. Reason: Adjusted code tags

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •