vba PasteSpecial does not work

0

I'm cropping the values from one worksheet to another. The clipping is done without problems, the data is going to the clipboard, but I am not able to paste.

Code

Private Sub CommandButton1_Click()
Dim raizen As String
Dim contador As Integer

contador = TextBox2.Value

If TextBox1.Text = "" Then
    MsgBox ("Informe um valor")
    Exit Sub
Else
    raizen = TextBox1.Text
End If

With Sheets("Plan1").Range("A:A")
Set c = .Find(raizen, LookIn:=xlValues, LookAt:=xlWhole)
ActiveCell.EntireRow.Cut
End With
Sheets("Plan2").Select
Sheets("Plan2").Range("A1").Select
Do Until ActiveCell.Value = ""
    ActiveCell.Offset(1, 0).Select
    contador = TextBox2.Value + 1
Loop
If ActiveCell.Value = "" Then
Worksheets("Plan2").Rows(contador).PasteSpecial Paste:=xlPasteValues
End If
TextBox2.Value = contador
End Sub
    
asked by anonymous 16.08.2016 / 13:20

1 answer

0

I found the answer! Since I am trimming and not copying I should use .Insert , which is equivalent to "inserting cropped cells" instead of using .Paste or .PasteSpecial.

Thank you !!!

    
16.08.2016 / 13:34