将单元格范围粘贴到第一个空行和空列

时间:2016-10-06 18:51:11

标签: excel vba

我想要实现的是从片材中复制3个第一个细胞" Arkusz1"并粘贴它#34; Arkusz2"到该列中的第一个空列和第一个空行。在此之后,该过程重新开始。我有代码将它粘贴到A列的第一个空行,但它不能正常工作,如上所述。我会帮助你。

Skok = Sheets("Arkusz3").Range("B1").Value
ActiveCellRow = ActiveCell.Row
Dim NextRow As Range
Set NextRow = Range(A + 1 & Sheets("Arkusz2").UsedRange.Rows.Count + 0)
Worksheets("Arkusz1").Activate
Sheets("Arkusz1").Range("A1").Select
ActiveCell.Offset(Skok, 0).Activate
Range("A1", ActiveCell.Offset(-1, 0)).Select
Selection.Copy
Worksheets("Arkusz2").Activate
NextRow.PasteSpecial Paste:=xlValues, Transpose:=False
Application.CutCopyMode = False
Set NextRow = Nothing

1 个答案:

答案 0 :(得分:1)

在这个例子中,我从第1张中取出A1,A2,A3,然后将其复制到第2张。然后,每次迭代(A4,A5,A6等等)将进入下一组。但是,我并不完全确定你的期望,所以这应该是一个良好的开端。

Dim s1a1 As String, s1a2 As String, s1a3 As String
Dim s2a1 As Long, s2a2 As Long, s2a3 As Long
Dim i As Integer

s2a1 = 1
s2a2 = 2
s2a3 = 3

For i = 1 To 6


s1a1 = Worksheets("Arkusz1").Cells(1, "A")
s1a2 = Worksheets("Arkusz1").Cells(2, "A")
s1a3 = Worksheets("Arkusz1").Cells(3, "A")

Worksheets("Arkusz2").Range("A" & s2a1) = s1a1
Worksheets("Arkusz2").Range("A" & s2a2) = s1a2
Worksheets("Arkusz2").Range("A" & s2a3) = s1a3

s2a1 = s2a1 + 3
s2a2 = s2a2 + 3
s2a3 = s2a3 + 3

Next i