+ Reply to Thread
Results 1 to 3 of 3

Populate Multiple rows from a Userform

Hybrid View

  1. #1
    Registered User
    Join Date
    11-30-2012
    Location
    Lincoln, England
    MS-Off Ver
    Excel 2010
    Posts
    2

    Populate Multiple rows from a Userform

    Good morning all,

    I'm trying to get my head round a problem I've got and I'm hoping you guys can help.
    I've got a userform that when used will copy the information on it to the first empty row on my spreadsheet, and it works nicely.
    I want to add multiple selections to the userform so that when you hit the 'Submit' button it will populate the first row with the first selection, the second row with the second etc until it hits an empty selection and then it will unload.

    I tried simply copying the code for the next entries but it just overwrites the previous information instead of moving down to the next row.
    Here's what I've got so far:

    Private Sub CommandButton1_Click()

    Dim iRow As Long
    Dim ws As Worksheet
    Set ws = Worksheets("Sheet4")

    iRow = ws.Cells.Find(What:="*", SearchOrder:=xlRows, _
    SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1

    If ComboBox1 = "" Then
    Unload Me
    Else
    With ws
    .Cells(iRow, 1).Value = Me.Doy.Value
    .Cells(iRow, 3).Value = Me.Cust.Value
    .Cells(iRow, 4).Value = Me.ComboBox1.Value
    .Cells(iRow, 5).Value = Me.Order1.Value
    End With
    End If

    If ComboBox2 = "" Then
    Unload Me
    Else
    With ws
    .Cells(iRow, 1).Value = Me.Doy.Value
    .Cells(iRow, 3).Value = Me.Cust.Value
    .Cells(iRow, 4).Value = Me.ComboBox2.Value
    .Cells(iRow, 5).Value = Me.Order2.Value
    End With
    End If


    End Sub


    As you can see, the iRow function should find the next empty row each time, but it isn't.
    Any help is gratefully recieved!

  2. #2
    Forum Contributor
    Join Date
    01-30-2013
    Location
    Wales
    MS-Off Ver
    Excel 2013
    Posts
    231

    Re: Populate Multiple rows from a Userform

    After the first endif add
    iRow = iRow+1

    Or put your iRow function between each combobox.
    Last edited by Chris 53; 03-25-2014 at 06:27 AM.
    Click * below if this answer helped

  3. #3
    Registered User
    Join Date
    11-30-2012
    Location
    Lincoln, England
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Populate Multiple rows from a Userform

    So simple, thank you so much!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. one userform to populate different rows but same column
    By kmakjop in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 12-09-2013, 06:34 PM
  2. [SOLVED] Listbox in userform to populate with all rows containing the Date today AND 2 weeks prior
    By cath1509 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-05-2013, 08:50 PM
  3. UserForm to populate multiple rows in a Worksheet
    By clapforthewolfman in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-05-2013, 01:11 PM
  4. Userform populate listbox with search from multiple textboxes
    By chendysworld in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-12-2012, 11:12 AM
  5. UserForm with Multiple ComboBoxes Populate
    By RobertCo in forum Excel General
    Replies: 2
    Last Post: 12-27-2006, 01:51 PM

Tags for this Thread

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