Consulting

Results 1 to 3 of 3

Thread: Solved: Copy row with condition thru userform

  1. #1
    VBAX Tutor
    Joined
    Sep 2007
    Posts
    265
    Location

    Solved: Copy row with condition thru userform

    Hi Expert,

    Can you advise me on how to copied row if the combobox changed with BOTH then copied to new row.

    Please find the attached file for your reference.
    Many thanks in advance.
    Rgds, Harto

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    Private Sub CommandButton1_Click()
    Dim Nrow As Integer
    With Sheets(1)

    Nrow = WorksheetFunction.CountA(.Range("B:B")) + 4

    .Cells(Nrow, 1).Value = .Cells(Nrow - 1, 1).Value + 1
    If ComboBox1.Value = "BOTH" Then
    .Cells(Nrow, 2).Value = "AAAA"
    .Cells(Nrow, 3).Value = TextBox2.Text
    .Cells(Nrow, 4).Value = TextBox3.Text
    .Cells(Nrow, 5).Value = TextBox4.Text
    .Cells(Nrow, 6).Value = TextBox5.Text
    Nrow = Nrow + 1
    .Cells(Nrow, 1).Value = .Cells(Nrow - 1, 1).Value + 1
    .Cells(Nrow, 2).Value = "BBBB"
    .Cells(Nrow, 3).Value = TextBox2.Text
    .Cells(Nrow, 4).Value = TextBox3.Text
    .Cells(Nrow, 5).Value = TextBox4.Text
    .Cells(Nrow, 6).Value = TextBox5.Text
    Else
    .Cells(Nrow, 2).Value = ComboBox1.Value
    .Cells(Nrow, 3).Value = TextBox2.Text
    .Cells(Nrow, 4).Value = TextBox3.Text
    .Cells(Nrow, 5).Value = TextBox4.Text
    .Cells(Nrow, 6).Value = TextBox5.Text
    End If
    Call getfocus
    End With

    End Sub
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Tutor
    Joined
    Sep 2007
    Posts
    265
    Location
    Thanks Bob.
    Appreciate it so much.

    Best, Harto

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •