• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Userform make it copy and paste in two Rows

kalua1231

Member
Hy guys, i am trying to find a way to make this userform to write giving information in two rows

Row One Having
ws.Cells(iRow, 3).Value = Me.textbox_name.Value
ws.Cells(iRow, 4).Value = Me.textbox_name.Value
ws.Cells(iRow, 5).Value = Range("C2").Value

and

Row Two having
ws.Cells(iRow, 4).Value = Me.textbox_name.Value
ws.Cells(iRow, 5).Value = Range("C2").Value


Original code is underneath this line, if you will need any additional information please feel free to ask. Thanks again Chandoo,
------------------------------------------------------------------------------------------


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

'check for a Name number
If Trim(Me.textbox_name.Value) = "" Then
Me.textbox_name.SetFocus
MsgBox "Please complete the form"
Exit Sub
End If

'copy the data to the database
ws.Cells(iRow, 3).Value = Me.textbox_name.Value
ws.Cells(iRow, 4).Value = Me.textbox_name.Value
ws.Cells(iRow, 5).Value = Range("C2").Value
 
When i click on the Add Task it duplicated the information in two rows the only information that will not be duplicated in the second row will be the information that is in the (C) column,

Hope this is more clearer.
 
Normally when you use a userform it only input information on one row, i am trying to get it to work, so that it may input the information on two rows.

Second row will have the same information as the first only difference will be leaving out the information that is on the (C) column for the second row.
 

Attachments

  • Fix 8 24.xlsm
    212.1 KB · Views: 2
Other pictures attached, trying to make it easier for everyone to understand. hope this works
 

Attachments

  • copy and paste What it does.jpg
    copy and paste What it does.jpg
    336.8 KB · Views: 3
  • copy and paste What i would like it to do for the second row.jpg
    copy and paste What i would like it to do for the second row.jpg
    340.9 KB · Views: 3
Try the following .. I just added two lines of code
Code:
Private Sub Cmdbutton_close_Click()
    Unload Me
End Sub

Private Sub CommandButton1_Click()
    Dim iRow As Long
    Dim ws As Worksheet
    Set ws = Worksheets("GENERAL")

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

    'check for a Name number
    If Trim(Me.textbox_name.Value) = "" Then
        Me.textbox_name.SetFocus
        MsgBox "Please complete the form"
        Exit Sub
    End If

    'copy the data to the database
    ws.Cells(iRow, 3).Value = Me.textbox_name.Value
    ws.Cells(iRow, 4).Value = Me.textbox_name.Value
    ws.Cells(iRow, 5).Value = Range("C2").Value
    ws.Cells(iRow + 1, 4).Value = Me.textbox_name.Value
    ws.Cells(iRow + 1, 5).Value = Range("C2").Value


    MsgBox "Data added", vbOKOnly + vbInformation, "Data Added"
    'clear the data
    Me.textbox_name.Value = ""
    Me.textbox_name.SetFocus
End Sub

As for the added lines are
Code:
    ws.Cells(iRow + 1, 4).Value = Me.textbox_name.Value
    ws.Cells(iRow + 1, 5).Value = Range("C2").Value
 
Back
Top