+ Reply to Thread
Results 1 to 4 of 4

Advice Please?

Hybrid View

  1. #1
    Greg
    Guest

    Advice Please?

    Hi all,

    I have this code below it is working well apart from the inputboxes, I want
    the person to have the ability to hit the cancel button. when this happens
    now it fills the column "g" completely with yes
    how can this be corrected.

    Private Sub UserForm_Activate()
    Sheet5.Activate
    Label1.Caption = InputBox("WHAT IS THE PLAYER'S REGISTRATION NUMBER?",
    "Existing Player's re-registration")

    Dim Nor
    Dim ans

    On Error Resume Next

    ans = Application.Match(CLng(Label1.Caption), Range("A:A"), 0)
    If Not IsError(ans) Then
    Label2.Caption = Application.Index(Range("B:B"), ans)
    Label3.Caption = Application.Index(Range("c:c"), ans)
    Application.Index(Range("j:j"), ans) = "YES"

    Else
    MsgBox "Invalid code"
    End If
    On Error GoTo 0
    Nor = MsgBox("IS THIS THE RIGHT PERSON?", vbYesNo)

    If Nor = vbNo Then
    Label1.Caption = InputBox("WHAT IS THE PLAYER'S REGISTRATION NUMBER?",
    "Existing Player's re-registration")

    Exit Sub
    End If

    If Nor = vbYes Then
    Unload Me
    QUESTION1.Show
    End If

    End Sub

    Thanks

    greg



  2. #2
    Forum Expert
    Join Date
    01-03-2006
    Location
    Waikato, New Zealand
    MS-Off Ver
    2010 @ work & 2007 @ home
    Posts
    2,243
    Hi Greg,

    The following allows for the pressing of cancel to be recognised - if you want further explanation have a look at the links in the code:

    'To end sub if "cancel" was pressed, sourced from _
    http://www.excelforum.com/showthread...vbcancel+input & http://vb.mvps.org/tips/varptr.asp
    If StrPtr(Label1.Caption) = 0 Then
    GoTo ExitSub
    Else
    End If

    hth
    Rob Brockett
    NZ
    Always learning & the best way to learn is to experience...

  3. #3
    Greg
    Guest

    Re: Advice Please?

    Thanks worked like a charm
    "broro183" <broro183.27hloy_1147088701.7645@excelforum-nospam.com> wrote in
    message news:broro183.27hloy_1147088701.7645@excelforum-nospam.com...
    >
    > Hi Greg,
    >
    > The following allows for the pressing of cancel to be recognised - if
    > you want further explanation have a look a the link in the code:
    >
    > 'To end sub if "cancel" was pressed, sourced from _
    > http://www.excelforum.com/showthread...vbcancel+input
    > & http://vb.mvps.org/tips/varptr.asp
    > If StrPtr(Label1.Caption) = 0 Then
    > GoTo ExitSub
    > Else
    > End If
    >
    > hth
    > Rob Brockett
    > NZ
    > Always learning & the best way to learn is to experience...
    >
    >
    > --
    > broro183
    > ------------------------------------------------------------------------
    > broro183's Profile:
    > http://www.excelforum.com/member.php...o&userid=30068
    > View this thread: http://www.excelforum.com/showthread...hreadid=539805
    >




  4. #4
    Forum Expert
    Join Date
    01-03-2006
    Location
    Waikato, New Zealand
    MS-Off Ver
    2010 @ work & 2007 @ home
    Posts
    2,243
    Hi Greg,
    Thanks for the feedback, pleased I could help by passing on others' knowledge ;-)

    Rob Brockett
    NZ
    Always learning & the best way to learn is to experience...

+ 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