+ Reply to Thread
Results 1 to 15 of 15

enter data from form into searched cells

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    07-10-2008
    Location
    UK
    Posts
    220

    enter data from form into searched cells

    Hi guys

    I have a userform with 5 text boxes and a command button.

    I also have a sheet with a large amount of data on it, arranged into sections with headings (sheet1).

    The user will enter the section heading he desires into textbox1, then other data into all of the other text boxes. Then click the command button.

    I need a code that will search sheet1 for the heading they entered into textbox one, then find the next empty cell BELOW the heading (in the same row). It will then put whatever the user entered in textbox2 into that cell, textbox3 in the cell directly to the right of it and textbox4 to the right of that one, and so on.

    Can anyone help?

  2. #2
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: enter data from form into searched cells

    Probably, but attach a small sample workbook illustrating your request.

  3. #3
    Forum Contributor
    Join Date
    07-10-2008
    Location
    UK
    Posts
    220

    Re: enter data from form into searched cells

    OK here is the example workbook, it explains how everything should work.
    Attached Files Attached Files

  4. #4
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: enter data from form into searched cells

    Like this? Not entirely sure how the data in your second sheet are laid out.
    Private Sub CommandButton1_Click()
    
    Dim r As Long, rFind As Range
    
    With Sheets("Storage")
        Set rFind = .Range("E:E").Find(what:=Me.TextBox1.Value, Lookat:=xlWhole)
        If Not rFind Is Nothing Then
            r = rFind.End(xlDown).Row + 1
            .Cells(r, 5).Value = Me.TextBox2.Value
            .Cells(r, 6).Value = Me.TextBox3.Value
            .Cells(r, 7).Value = Me.TextBox4.Value
            .Cells(r, 8).Value = Me.TextBox5.Value
        End If
    End With
            
    End Sub

  5. #5
    Forum Contributor
    Join Date
    07-10-2008
    Location
    UK
    Posts
    220

    Re: enter data from form into searched cells

    I cant get it to work..i have tried changing it to the following cod but it still just seems to do nothing...

    Private Sub AddNewOrder_Click()
    
    Dim r As Long, rFind As Range
    
    With Sheets("Bristol Order Storage").UsedRange
        Set rFind = .Find(what:=Me.AddNewOrderTextBox1.Value, Lookat:=xlWhole)
        If Not rFind Is Nothing Then
            r = rFind.End(xlDown).Row + 1
            .Cells(r, 5).Value = Me.AddNewOrderTextBox2.Value
            .Cells(r, 6).Value = Me.AddNewOrderTextBox3.Value
            .Cells(r, 7).Value = Me.AddNewOrderTextBox4.Value
            .Cells(r, 8).Value = Me.AddNewOrderTextBox5.Value
        End If
    End With
            
    End Sub

  6. #6
    Forum Contributor
    Join Date
    07-10-2008
    Location
    UK
    Posts
    220

    Re: enter data from form into searched cells

    If you look at the examplt workbook, on the storage sheet there is one section for data to sit..headed 'John smith' in the read workbook there will be numerous sections all with different headings, thats why the user has to define in the userform which section he wants to add to.

  7. #7
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: enter data from form into searched cells

    Your storage sheet totally ignores all the rules for storing data. All the data should be in a table format, with headers & no empty columns or rows between data entries. Then it will be simple to implement a userform. Your layout as you are finding is just creating unnecessary problems
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  8. #8
    Forum Contributor
    Join Date
    07-10-2008
    Location
    UK
    Posts
    220

    Re: enter data from form into searched cells

    Oh ok, here is a copy of the actual sheet I will be using. is that any better?
    Attached Files Attached Files

  9. #9
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: enter data from form into searched cells

    Quote Originally Posted by twofootgiant View Post
    Oh ok, here is a copy of the actual sheet I will be using. is that any better?
    No,it still is not designed as an Excel Database should be. Have a look at this
    Attached Files Attached Files

  10. #10
    Forum Contributor
    Join Date
    07-10-2008
    Location
    UK
    Posts
    220

    Re: enter data from form into searched cells

    Please see attached file.
    Attached Files Attached Files

  11. #11
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: enter data from form into searched cells

    You could simply enter the data into the database then sort by name

  12. #12
    Forum Contributor
    Join Date
    07-10-2008
    Location
    UK
    Posts
    220

    Re: enter data from form into searched cells

    ok, thats not what i want....

    forget doing it that way then...

    is there a way of doing it with the layout in testforsite.xlsx that i posted earlier...i realise that it will be a more complicated code but because of other factors in the final workbook it will be alot simpler doing it that way in the end.

    Can it be done? If so will you help me ammend the code I have tried?

  13. #13
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: enter data from form into searched cells

    I'll have a look later

  14. #14
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: enter data from form into searched cells

    I think this is what you want
    Attached Files Attached Files

+ 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