+ Reply to Thread
Results 1 to 3 of 3

UserForm Entering Data Into Excel Rows

Hybrid View

  1. #1
    Registered User
    Join Date
    06-13-2013
    Location
    Atlanta
    MS-Off Ver
    Excel 2010
    Posts
    4

    UserForm Entering Data Into Excel Rows

    Hello everyone!

    I have a dataset with a long list of Rows, with Column headers that contains ID numbers and some ‘other information’. I currently have a UserForm created that has text boxes which ask the User to input the ID number they are looking for, and the ‘other information’ they would like to update into the dataset. What I would like help on is the code for the command button that would find the ID number under the column header, and to automatically transfer the ‘other information’ the user inputted into the same row (the one that matches the ID number).

    I currently have a rough start; my code only transfers the UserForm inputs into the next empty rows.


    
    Private Sub cmdUpdate_Click()
    
    Dim eRow As Long
    Worksheets("Sheet3").Activate
    eRow = Worksheets("Sheet3").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
    Cells(eRow, 3) = TextBox1.Text
    Cells(eRow, 7) = TextBox2.Text
    Cells(eRow, 8) = TextBox3.Text
    Cells(eRow, 11) = TextBox4.Text
    
    End Sub

    I would my code to transfer the UserForm inputs into the column that match another ID that is in the existing row. To illustrate, under Column A, I have thousands of ID numbers that are already listed. I want the UserForm to update information to the correct row identified by the unique ID number.


    Any help would be greatly appreciated!

  2. #2
    Forum Contributor
    Join Date
    01-02-2007
    Location
    Australia NSW
    MS-Off Ver
    2013
    Posts
    494

    Re: UserForm Entering Data Into Excel Rows

    How is the ID selected?
    Application.ScreenUpdating = False
    Dim rng As Variant
          With Sheets("Sheet3").Range("A:A") ' Search ID assume in Column A
        Set rng = .Find(What:=Val(Me.TextBox1.Value), After:=.Cells(1), LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False) ' Assumes Textbox1 is where the ID was selected
        If rng <> "" Then
        rng= TextBox1.Text
    rng.offset(,2)= TextBox1.Text
    rng.offset(,6)= TextBox2.Text
    rng.offset(,7)= TextBox3.Text
    rng.offset(,10)= TextBox4.Text
    End if
    End With
    
    Application.ScreenUpdating = True

  3. #3
    Registered User
    Join Date
    06-13-2013
    Location
    Atlanta
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: UserForm Entering Data Into Excel Rows

    Thanks for the reply, I'll try out your code.

    So the user should know the ID and input that into the UserForm, along with the additional information. My code currently doesn't do anything with the ID, but it should ideally match the input with the row, and automatically insert the additional information. Does that answer your question?

+ 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