I am trying to copy Cells from one Worksheet to another Worksheet if a giving condition is met. I know how to make it work with one value using the following code :
Private Sub CommandButton1_Click()
Dim CustomerName As String, Phone As String
Worksheets("Tabelle1").Select
CustomerName = Range("A2")
Phone = Range("B2")
Worksheets("Tabelle2").Select
Worksheets("Tabelle2").Range("A1").Select
If Worksheets("Tabelle2").Range("A1").Offset(1, 0) <> "" Then
Worksheets("Tabelle2").Range("A1").End(xlDown).Select
End If
If Worksheets("Tabelle1").Range("B2").Value = "Pooe" Then
ActiveCell.Offset(1, 0).Select
ActiveCell.Value = CustomerName
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = Phone
End If
End Sub
If I now try to the same with the entire column I get the "type mismatch" error.
Private Sub CommandButton1_Click()
Dim CustomerName As String, Phone As String
Worksheets("Tabelle1").Select
CustomerName = Range("A2")
Phone = Range("B2")
Worksheets("Tabelle2").Select
Worksheets("Tabelle2").Range("A1").Select
If Worksheets("Tabelle2").Range("A1").Offset(1, 0) <> "" Then
Worksheets("Tabelle2").Range("A1").End(xlDown).Select
End If
If Worksheets("Tabelle1").Range("B:B").Value = "Pooe" Then
ActiveCell.Offset(1, 0).Select
ActiveCell.Value = CustomerName
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = Phone
End If
End Sub
The goal is to copy the entire row of the first worksheet to the second worksheet, if in the first worksheet the condition (Column B = "Pooe" ) is matched. Does anybody know how to make it work ?