Copy row where cell is changed

  • Hello,


    And (Spike) Thanks (again) for the code below

    Code
    If Me.ComboBox2.ListIndex <> 0 Then
    Sheets("FSM").Cells(Me.ComboBox1.ListIndex + 1, 3) = Me.ComboBox2.Value
    Me.TextBox1.Value = Me.ComboBox2.Value
    End If


    So when with this code the cell value is changed in the combobox value.
    How can I than select the row that is changed - copy it and paste the row in an other sheet?


    .....;Hope this is understandably.


    aisietie

  • Re: Copy row where cell is changed


    Hello,


    With the code below, the problem is partially solved.
    But when multiple cells contains the combobox value, then the code finds the first cell that contains the value, and not the one that was changed.



    What can I change to obtain what I want?


    Thx in advance


    aisietie

  • Re: Copy row where cell is changed


    Hi aisietie
    You can use your combobox index as in this case it directly related to the rows if we add 1 to it

    Code
    Private Sub CommandButton1_Click()
        If Me.ComboBox2.ListIndex <> 0 Then
            Sheets("FSM").Cells(Me.ComboBox1.ListIndex + 1, 3) = Me.ComboBox2.Value
            Me.TextBox1.Value = Me.ComboBox2.Value
        End If
          Sheets("FSM").Range("A" & ComboBox1.ListIndex + 1 & ":C" & & ComboBox1.ListIndex + 1).Copy Destination:=Worksheets("test").Cells(Rows.Count, "A").End(xlUp).Offset(1, 0)
         Unload UserForm1
    End Sub

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!