+ Reply to Thread
Results 1 to 23 of 23

Help with Userform textbox value, vlookup, copy to clipboard

Hybrid View

  1. #1
    Registered User
    Join Date
    12-08-2010
    Location
    Philippines
    MS-Off Ver
    Office 365
    Posts
    76

    Help with Userform textbox value, vlookup, copy to clipboard

    sample dbase - Copy.xlsm

    I'm working on this project and this how it works.

    the form consist of several text boxes. data is required for each textboxes
    Add to dB will insert all data entered in "DB PIT" sheet. (Its already working)

    now, here is what I'm trying to achieve
    1. I want to have one value on a textbox (as I enter it) to be the same with another textbox.
    2. Since all data are saved on DB PIT sheet, I want to gather data using 2 criteria, 1 is by TIN (first text box) and another is by Hub ID. As soon as I enter the TIN or Hub ID, the rest of the data will be populated on each text boxes if it already exists on the "DB PIT" Sheet.
    3. Lastly, There is a big text box on the lower right, I want to put a template on that area where all the data that I put in will be reflected on that textbox, once all the data is completed, it can easily be copied by just pressing the copy to clipboard button.

    Thank you Guys!

  2. #2
    Registered User
    Join Date
    12-08-2010
    Location
    Philippines
    MS-Off Ver
    Office 365
    Posts
    76

    Re: Help with Userform textbox value, vlookup, copy to clipboard

    anyone please?

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Help with Userform textbox value, vlookup, copy to clipboard

    Hello etuckram,

    This code assumes the name of the button on the user form is "Command Button 1". You can copy the code between the Sub and End Sub statements into your button's click event. Change the TextBox to match yours.
    
    Private Sub CommandButton1_Click()
    
        Dim DataObj As DataObject
        
            Set DataObj = New DataObject
            
            With DataObj
                .SetText TextBox1.Text
                .PutInClipboard
            End With
            
    End Sub
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  4. #4
    Registered User
    Join Date
    12-08-2010
    Location
    Philippines
    MS-Off Ver
    Office 365
    Posts
    76

    Re: Help with Userform textbox value, vlookup, copy to clipboard

    Quote Originally Posted by Leith Ross View Post
    Hello etuckram,

    This code assumes the name of the button on the user form is "Command Button 1". You can copy the code between the Sub and End Sub statements into your button's click event. Change the TextBox to match yours.
    
    Private Sub CommandButton1_Click()
    
        Dim DataObj As DataObject
        
            Set DataObj = New DataObject
            
            With DataObj
                .SetText TextBox1.Text
                .PutInClipboard
            End With
            
    End Sub
    thank you! It works perfect!

    1. I want to have one value on a textbox (as I enter it) to be the same with another textbox. - SOLVED

    2. Since all data are saved on DB PIT sheet, I want to gather data using 2 criteria, 1 is by TIN (first text box) and another is by Hub ID. As soon as I enter the TIN or Hub ID, the rest of the data will be populated on each text boxes if it already exists on the "DB PIT" Sheet.
    3. Lastly, There is a big text box on the lower right, I want to put a template on that area where all the data that I put in will be reflected on that textbox, once all the data is completed, it can easily be copied by just pressing the copy to clipboard button. - SOLVED

  5. #5
    Registered User
    Join Date
    12-08-2010
    Location
    Philippines
    MS-Off Ver
    Office 365
    Posts
    76

    Re: Help with Userform textbox value, vlookup, copy to clipboard

    Additional:

    In Vba,

    on txtbox1, when I enter abcdef111.company.com on that textbox1 it will return with a result on textbox2 with company.com

    so basically it will remove the character after the first "."
    this is what I have on excel, "=RIGHT(B17,LEN(B17)-SEARCH(".",B17))"

    what is the equivalent of that in VBA?

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Help with Userform textbox value, vlookup, copy to clipboard

    Hello etuckram

    Her is one way...
    
        Dim s As Variant
        
            s = Split(TextBox1.Value, ".")
            
            TextBox2.Value = s(UBound(s) - 1) & "." & s(UBound(s))

  7. #7
    Registered User
    Join Date
    12-08-2010
    Location
    Philippines
    MS-Off Ver
    Office 365
    Posts
    76

    Re: Help with Userform textbox value, vlookup, copy to clipboard

    Quote Originally Posted by Leith Ross View Post
    Hello etuckram

    Her is one way...
    
        Dim s As Variant
        
            s = Split(TextBox1.Value, ".")
            
            TextBox2.Value = s(UBound(s) - 1) & "." & s(UBound(s))
    it says, subscript out of range

  8. #8
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Help with Userform textbox value, vlookup, copy to clipboard

    Hello etuckram,

    You would get that error message if the TextBox1 is empty.

  9. #9
    Registered User
    Join Date
    12-08-2010
    Location
    Philippines
    MS-Off Ver
    Office 365
    Posts
    76

    Re: Help with Userform textbox value, vlookup, copy to clipboard

    Quote Originally Posted by Leith Ross View Post
    Hello etuckram,

    You would get that error message if the TextBox1 is empty.
    as soon as I type a Letter on textbox1, it will give me that error.

  10. #10
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Help with Userform textbox value, vlookup, copy to clipboard

    Hello etuckram.

    You should be validating the entry after it has been entered and not during entry. Move the code from the Change event to the Click event.

  11. #11
    Registered User
    Join Date
    12-08-2010
    Location
    Philippines
    MS-Off Ver
    Office 365
    Posts
    76

    Re: Help with Userform textbox value, vlookup, copy to clipboard

    Quote Originally Posted by Leith Ross View Post
    Hello etuckram.

    You should be validating the entry after it has been entered and not during entry. Move the code from the Change event to the Click event.
    Private Sub txtOut_AfterUpdate()
    txtDomain_Change
    End Sub
    
    Private Sub txtDomain_Change()
    
        Dim s As Variant
        
            s = Split(txtOut.Value, ".")
            
            txtDomain.Value = s(UBound(s) - 1) & "." & s(UBound(s))
        
    End Sub
    it gave me the same value

  12. #12
    Registered User
    Join Date
    12-08-2010
    Location
    Philippines
    MS-Off Ver
    Office 365
    Posts
    76

    Re: Help with Userform textbox value, vlookup, copy to clipboard

    also, can we write a code that would ignore the word if no "." period was found?

  13. #13
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Help with Userform textbox value, vlookup, copy to clipboard

    Hllo etuckram,

    You need only the AfterUpate event code. Remove the other event code modules for this TextBox.
    Private Sub txtDomain_AfterUpdate()
    
        Dim s As Variant
        
            s = Split(txtOut.Value, ".")
            
            If UBound(s) > 0 Then txtDomain.Value = s(UBound(s) - 1) & "." & s(UBound(s))
        
    End Sub

  14. #14
    Registered User
    Join Date
    12-08-2010
    Location
    Philippines
    MS-Off Ver
    Office 365
    Posts
    76

    Re: Help with Userform textbox value, vlookup, copy to clipboard

    it works now....

    also, can we write a code that would ignore the word if no "." period was found?

  15. #15
    Registered User
    Join Date
    12-08-2010
    Location
    Philippines
    MS-Off Ver
    Office 365
    Posts
    76

    Re: Help with Userform textbox value, vlookup, copy to clipboard

    it perfectly works now, the problem is
    when i enter
    word.marky.domain.com, the return is domain.com
    I just want to remove the first word before the first dot.

  16. #16
    Registered User
    Join Date
    12-08-2010
    Location
    Philippines
    MS-Off Ver
    Office 365
    Posts
    76

    Re: Help with Userform textbox value, vlookup, copy to clipboard

    This worked for me:
    copy textbox value to clipboard
    Private Sub CommandButton1_Click()
    
        Dim DataObj As DataObject
        
            Set DataObj = New DataObject
            
            With DataObj
                .SetText TextBox1.Text
                .PutInClipboard
            End With
            
    End Sub


    Additional:

    In Vba,

    on txtbox1, when I enter abcdef111.company.com on that textbox1 it will return with a result on textbox2 with company.com

    so basically it will remove the character after the first "."
    this is what I have on excel, "=RIGHT(B17,LEN(B17)-SEARCH(".",B17))"

    what is the equivalent of that in VBA?




    Private Sub txtDomain_AfterUpdate()
    
      Dim i As Long
        
            i = InStr(1, txtOut, ".")
        
            If i > 0 Then txtDomain = Right(txtOut, Len(txtOut) - i)
    
    
        
    End Sub

  17. #17
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Help with Userform textbox value, vlookup, copy to clipboard

    Hello etuckram,

    Private Sub txtDomain_AfterUpdate()
    
        Dim i as Long
        Dim Text As String
    
            Text = txtDomain.Value
            If InStr(1, Text, ".")  > 0 Then txtDomain.Value = Right(Text, Len(Text) - i)
        
    End Sub

  18. #18
    Registered User
    Join Date
    12-08-2010
    Location
    Philippines
    MS-Off Ver
    Office 365
    Posts
    76

    Re: Help with Userform textbox value, vlookup, copy to clipboard

    Quote Originally Posted by Leith Ross View Post
    Hello etuckram,

    Private Sub txtDomain_AfterUpdate()
    
        Dim i as Long
        Dim Text As String
    
            Text = txtDomain.Value
            If InStr(1, Text, ".")  > 0 Then txtDomain.Value = Right(Text, Len(Text) - i)
        
    End Sub
    I appreciate your help, but its not working, its giving me the same value

  19. #19
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Help with Userform textbox value, vlookup, copy to clipboard

    Hello etuckram,

    What should the before and after values look like?

  20. #20
    Registered User
    Join Date
    12-08-2010
    Location
    Philippines
    MS-Off Ver
    Office 365
    Posts
    76

    Re: Help with Userform textbox value, vlookup, copy to clipboard

    txtOut = mmmm1.marky.company.com
    txtDomain = marky.company.com

    If I enter mmmm1.marky.company.com, I will get marky.company.com on txtDomain

  21. #21
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Help with Userform textbox value, vlookup, copy to clipboard

    Hello etuckram,

    This produces the correct result for me...
    
        Dim i As Long
        
            i = InStr(1, txtOut, ".")
        
            If i > 0 Then txtDomain = Right(txtOut, Len(txtOut) - i)

  22. #22
    Registered User
    Join Date
    12-08-2010
    Location
    Philippines
    MS-Off Ver
    Office 365
    Posts
    76

    Re: Help with Userform textbox value, vlookup, copy to clipboard

    Quote Originally Posted by Leith Ross View Post
    Hello etuckram,

    This produces the correct result for me...
    
        Dim i As Long
        
            i = InStr(1, txtOut, ".")
        
            If i > 0 Then txtDomain = Right(txtOut, Len(txtOut) - i)
    Thank you, I'm almost there....

    1. I want to have one value on a textbox (as I enter it) to be the same with another textbox. - SOLVED
    2. Since all data are saved on DB PIT sheet, I want to gather data using 2 criteria, 1 is by TIN (first text box) and another is by Hub ID. As soon as I enter the TIN or Hub ID, the rest of the data will be populated on each text boxes if it already exists on the "DB PIT" Sheet.
    3. Lastly, There is a big text box on the lower right, I want to put a template on that area where all the data that I put in will be reflected on that textbox, once all the data is completed, it can easily be copied by just pressing the copy to clipboard button. - SOLVED

  23. #23
    Registered User
    Join Date
    12-08-2010
    Location
    Philippines
    MS-Off Ver
    Office 365
    Posts
    76

    Re: Help with Userform textbox value, vlookup, copy to clipboard

    Hi Everyone,

    I'm currently working on a User Form in Excel. I'm almost done with it I just need one last piece of info.

    This Userform consists of textboxes
    ex:
    txtbox1
    txtbox2
    txtbox3
    txtbox4
    txtbox5

    now, initially you would enter any value on each textbox then there is button on that userform that would past all the information on a sheet name "Database"

    now, what I want to happen is to automatically populate values of txtbox 2 to 5 if the value of txtbox1 was recently added to the "database" sheet. If no matches found, then just add the assigned date as the date today like what I have on my code.

    This is my code and it is not working...

    Private Sub txtTIN_AfterUpdate()
    
    On Error GoTo ErrHandler
    
        If IsNewOrder(txtbox1.Value) = False Then
            txtbox2.Text = Worksheets("Database").Cells(OrderRow, 3).Value
            txtbox3.Text = Worksheets("Database").Cells(OrderRow, 4).Value
            txtbox4.Text = Worksheets("Database").Cells(OrderRow, 5).Value
            txtbox5.Text = Worksheets("Database").Cells(OrderRow, 6).Value
    
        Else
            txtDate.Text = Format(Now(), "mm/dd/yyyy")
        End If
    
        Exit Sub
    
    ErrHandler:
        If Err.Number = 13 Then Resume Next
    End Sub
    
    Private Function IsNewOrder(SearchKey As String) As Boolean
        
    On Error GoTo ErrCheck
    
    Dim OrderRow As Long
           
        OrderRow = Application.Match(SearchKey, Sheets("Database").Range("B:B"), 0)
        If OrderRow = 0 Then IsNewOrder = True
    
    Exit Function
    
    ErrCheck:
    
    If Err.Number = 13 Then
        OrderRow = 0
        IsNewOrder = True
        Resume Next
    End If
    
    End Function
    Please help... 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