我不能只粘贴值。
我的代码:
Private Sub CommandButton5_Click()
'Komanda rinkti duomenis
a = Worksheets("Lapas1").Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To a
If Worksheets("lapas1").Cells(i, 3).Value = Range("K5") Then
Worksheets("lapas1").Rows(i).Copy
Worksheets("Sàskaita-Faktûra").Activate
b = Worksheets("Sàskaita-Faktûra").Cells(Rows.Count, 1).End(xlUp).Row
Worksheets("Sàskaita-Faktûra").Cells(b + 1, 1).Select
ActiveSheet.Paste
Worksheets("lapas1").Activate
End If
Next
Application.CutCopyMode = False
Worksheets("Sàskaita-Faktûra").Activate
Range("K5").Activate
End Sub
已经尝试:
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
答案 0 :(得分:0)
尝试一下:
Private Sub CommandButton5_Click()
Dim shtSrc as worksheet, shtDest as worksheet, i as long
Set shtSrc = Worksheets("Lapas1")
Set shtDest = Worksheets("Sàskaita-Faktûra")
'Komanda rinkti duomenis
For i = 2 To shtSrc.Cells(Rows.Count, 1).End(xlUp).Row
If shtSrc.Cells(i, 3).Value = shtDest.Range("K5").Value Then 'K5 sheet?
shtDest.Cells(rows.count, 1).end(xlup).offset(1, 0).Entirerow.value = _
shtSrc.rows(i).value
End If
Next
shtDest.Activate
shtDest.Range("K5").Activate
End Sub