这是我的表1(源数据);
我需要"复制"只有行,A7:C1009范围内的整行不是空白。然后应该从表格中的A7开始在表格2(目的地)中输入该选择;
我设法让这个VBA工作,但它将包括所有行(也包括行,其中A:C都是空白/空;
Private Sub CommandButton1_Click()
Dim ws1 As Worksheet, ws2 As Worksheet
Dim cl1 As Range, rng1 As Range, rng2 As Range, rng3 As Range
Dim r As Long, c As Long
Set ws1 = Worksheets("Indkøb") 'Indkøb
Set ws2 = Worksheets("Kalkulation3") 'Kalkulation3
Set rng1 = ws1.Range("a7:a1009")
Set rng2 = ws1.Range("b7:b1009")
Set rng3 = ws1.Range("c7:c1009")
For Each cl1 In rng1
r = cl1.Row
c = cl1.Column
If cl1.Value <> ws2.Cells(r, c).Value Then
ws2.Cells(r, c).EntireRow.Insert
ws2.Cells(r, c).Value = cl1.Value
End If
Next cl1
For Each cl1 In rng2
r = cl1.Row
c = cl1.Column
If cl1.Value <> ws2.Cells(r, c).Value Then
ws2.Cells(r, c).Value = cl1.Value
End If
Next cl1
For Each cl1 In rng3
r = cl1.Row
c = cl1.Column
If cl1.Value <> ws2.Cells(r, c).Value Then
ws2.Cells(r, c).Value = cl1.Value
End If
Next cl1
End Sub
这就是我想要完成的事情;
非常感谢有关如何使这项工作的任何意见。谢谢: - )
答案 0 :(得分:0)
这将完成你想要的#1请求。您将需要一个不同的宏来完成您的#2请求。对不起,我无法帮助你。
Dim lRow As Long
lRow = Cells(Rows.Count, 1).End(xlUp).Row
For i = 7 To lRow
If IsEmpty(Cells(i, 1)) And IsEmpty(Cells(i, 2)) And IsEmpty(Cells(i, 3)) Then
Rows(i).EntireRow.Hidden = True
End If
Next i
Dim Rng As Range
Set Rng = ActiveSheet.Cells.SpecialCells(xlCellTypeVisible)
Rng.Copy Destination:=Sheets("Sheet2").Range("A7")