+ Reply to Thread
Results 1 to 4 of 4

Help with UserForm textbox code

Hybrid View

  1. #1
    excelnut1954
    Guest

    Help with UserForm textbox code

    I thought I posted this question last Friday. But, I can't find it.
    Maybe I didn't actually finish posting it.....

    I have deigned a UserForm that will allow the user to enter some info
    that will be copied to a worksheet when the user clicks the OK button.
    There are about a dozen fields the user will enter info to.

    I have code that will look at the textbox1 entry, and compare it with
    the data already in column J of this list, and warn the user if this
    data already exists.. This works fine, except that I would like it to
    identify this duplicate as soon as the user tabs out of textbox1. Right
    now, it will perform this check only after the OK button is clicked,
    when the whole UserForm is completed. I'd like to save the user from
    entering in all the data that will not be copied to the list anyway.

    Here is the current code to perform the check to find a duplicate when
    it compares the textbox1 entry vs entries in column J of the worksheet:

    With Worksheets("Official list")
    If Application.CountIf(.Range("j:j"), TextBox1.Text) > 0 Then
    MsgBox "This PO/PL is already on the list. Please edit the existing
    record "
    TextBox1.Text = Clear

    Else

    Range("J65536").End(xlUp)(2).Select
    Application.Selection.Value = TextBox1.Text

    End If

    End With


    Thanks for your help/suggestions.
    J.O.


  2. #2
    Toppers
    Guest

    RE: Help with UserForm textbox code

    Hi,
    Add this to the Uerform code:

    Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)

    With Worksheets("Official list")
    If Application.CountIf(.Range("j:j"), TextBox1.Text) > 0 Then
    MsgBox "This PO/PL is already on the list. Please edit the existing
    Record """
    TextBox1.Text = Clear

    Else

    Range("J65536").End(xlUp)(2).Select
    Application.Selection.Value = TextBox1.Text

    End If

    End With

    End Sub


    HTH

    "excelnut1954" wrote:

    > I thought I posted this question last Friday. But, I can't find it.
    > Maybe I didn't actually finish posting it.....
    >
    > I have deigned a UserForm that will allow the user to enter some info
    > that will be copied to a worksheet when the user clicks the OK button.
    > There are about a dozen fields the user will enter info to.
    >
    > I have code that will look at the textbox1 entry, and compare it with
    > the data already in column J of this list, and warn the user if this
    > data already exists.. This works fine, except that I would like it to
    > identify this duplicate as soon as the user tabs out of textbox1. Right
    > now, it will perform this check only after the OK button is clicked,
    > when the whole UserForm is completed. I'd like to save the user from
    > entering in all the data that will not be copied to the list anyway.
    >
    > Here is the current code to perform the check to find a duplicate when
    > it compares the textbox1 entry vs entries in column J of the worksheet:
    >
    > With Worksheets("Official list")
    > If Application.CountIf(.Range("j:j"), TextBox1.Text) > 0 Then
    > MsgBox "This PO/PL is already on the list. Please edit the existing
    > record "
    > TextBox1.Text = Clear
    >
    > Else
    >
    > Range("J65536").End(xlUp)(2).Select
    > Application.Selection.Value = TextBox1.Text
    >
    > End If
    >
    > End With
    >
    >
    > Thanks for your help/suggestions.
    > J.O.
    >
    >


  3. #3
    excelnut1954
    Guest

    Re: Help with UserForm textbox code

    Thanks Toppers

    I have a different twist of this problem. The problem you responded to,
    I figured out. I had the coding in the wrong sub. I thought I removed
    the post before anyone would respond to it.

    HOWEVER
    If you read my new entry I just entered, maybe you can help with this
    problem.

    Thanks,
    J.O.


  4. #4
    excelnut1954
    Guest

    Re: Help with UserForm textbox code

    Please see the new post Coding questions about UserForm TextBox.

    I have this one all screwed up...

    Thanks,
    J.O.


+ 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