vba Pastespecial does not work

Asked

Viewed 184 times

0

I’m cutting the values out of one spreadsheet and moving on to the other. The clipping is done without problems, the data is going to the clipboard, but I’m 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
  • Jeez, the question text lost all the formatting :S

  • Thanks for the edition!

1 answer

0

I found the answer! How am I cropping and not copying I should use .Insert, which is the equivalent of "insert cropped cells" instead of using . Paste or . Pastspecial.

Thank you!!!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.