1
我有一個copy-if例程,在找到如何粘貼值時遇到問題。有人可以幫忙嗎?PasteSpecial(Values)in「copy if code」
我的做法如下:
Sub CopyRowsAcross()
Dim i As Integer
Dim ws1 As Worksheet: Set ws1 = Workbooks("Bok2.xlsx").Sheets("Ark1")
Dim ws2 As Worksheet: Set ws2 = Workbooks("Bok2.xlsx").Sheets("Ark2")
Dim ws3 As Worksheet: Set ws3 = ThisWorkbook.Sheets("Ark1")
For i = 2 To ws1.Range("A100").End(xlUp).Row
If ws1.Cells(i, 1) = "Videreføres" Then ws2.Range("B1:B100")(i).Copy ws3.Range("A1:A100")(ws3.Cells(ws3.Range("A1:A100").Count, 1).End(xlUp).Row + 1)
If ws1.Cells(i, 1) = "Videreføres" Then ws2.Range("C1:C100")(i).Copy ws3.Range("B1:B100")(ws3.Cells(ws3.Range("B1:B100").Count, 1).End(xlUp).Row + 0)
If ws1.Cells(i, 1) = "Videreføres" Then ws2.Range("E1:E100")(i).Copy ws3.Range("C1:C100")(ws3.Cells(ws3.Range("C1:C100").Count, 1).End(xlUp).Row + 0)
Next i
End Sub
完美的作品!非常感謝你! –