+ Reply to Thread
Results 1 to 10 of 10

User Form adding records in 2 rows at a time

  1. #1
    Registered User
    Join Date
    01-24-2009
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    13

    User Form adding records in 2 rows at a time

    Hi,

    I created a user form & every thing is recording perfect, but i would like to add the information in 2 rows at a same time.
    Example :

    Date : 05/11/12
    Part No. : ABC
    Receiver : R1
    Sender : S1
    Quantity : 100

    When i click the button to add the above records, have to add the following manner :

    Date : Part No. Name Quantity
    1. 05/11 ABC R1 100
    2. 05/11 ABC S1 100

    I have acoding for single record, but i would like to know who can i record using one form to record two different rows, but have all the information same except the name.

    Waiting your reply.

    Regards,

    Misbah
    Last edited by sheikhmisbah; 05-20-2012 at 03:59 PM.

  2. #2
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: User Form adding records in 2 rows at a time

    Hi Misbah
    Why don't you show us you're existing code (be sure to use Code Tags).
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  3. #3
    Registered User
    Join Date
    01-24-2009
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: User Form adding records in 2 rows at a time

    Hi Jaslake,

    Thank you very much for your reply.
    As per your request, following are the codes :

    Private Sub cmdAdd_Click()
    Dim lRow As Long
    Dim lPart As Long
    Dim ws As Worksheet
    Set ws = Worksheets("PartsData")

    'find first empty row in database
    ''lRow = ws.Cells(Rows.Count, 1) _
    '' .End(xlUp).Offset(1, 0).Row

    'revised code to avoid problems with
    'Excel lists and tables in newer versions
    lRow = ws.Cells.Find(What:="*", SearchOrder:=xlRows, _
    SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1

    lPart = Me.cboPart.ListIndex

    'check for a part number
    If Trim(Me.cboPart.Value) = "" Then
    Me.cboPart.SetFocus
    MsgBox "Please enter a part number"
    End If
    If Trim(Me.cboLocation.Value) = "" Then
    Me.cboLocation.SetFocus
    MsgBox "Please enter the Location"
    Exit Sub
    End If

    'copy the data to the database
    With ws
    .Cells(lRow, 1).Value = Me.txtDate.Value
    .Cells(lRow, 2).Value = Me.cboLocation.Value
    .Cells(lRow, 4).Value = Me.cboPart.Value
    .Cells(lRow, 5).Value = Me.cboPart.List(lPart, 1)
    .Cells(lRow, 9).Value = Me.txtQty.Value
    .Cells(lRow, 11).Value = Me.txtQty2.Value
    .Cells(lRow, 7).Value = Me.txtQty3.Value
    .Cells(lRow, 8).Value = Me.txtQty4.Value
    'new addition


    End With

    'clear the data
    Me.cboPart.Value = ""
    Me.cboLocation.Value = ""
    Me.cboLocation2.Value = ""
    Me.txtDate.Value = Format(Date, "Medium Date")
    Me.txtQty.Value = ""
    Me.cboPart.SetFocus

    End Sub

  4. #4
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: User Form adding records in 2 rows at a time

    Hi Misbah

    Please wrap your code in Code Tags...the Moderators are rather strict on this.

    Rule #3. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Select your code and click the [#] button at the top of the post window (if you are editing an existing post, press Go Advanced to see the [#] button). You can also type the code tags in manually if you prefer.

  5. #5
    Registered User
    Join Date
    01-24-2009
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: User Form adding records in 2 rows at a time

    Please Login or Register  to view this content.

  6. #6
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: User Form adding records in 2 rows at a time

    Hi Misbah

    Perfect.

  7. #7
    Registered User
    Join Date
    01-24-2009
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: User Form adding records in 2 rows at a time

    Thanks Jaslake

  8. #8
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: User Form adding records in 2 rows at a time

    Hi Misbah

    Without seeing your workbook and UserForm, I'd suggest looking at this approach
    Please Login or Register  to view this content.
    If this doesn't work for you then I'll need to see the workbook with the UserForm and existing code. Let me know of issues.

  9. #9
    Registered User
    Join Date
    01-24-2009
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: User Form adding records in 2 rows at a time

    Thank you very much & I really appreciate for your help.

    Best Regards,

    Mibah

  10. #10
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: User Form adding records in 2 rows at a time

    Hi Misbah

    You're welcome...glad I could help. If this satisfies your need, please mark your Thread as Solved.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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