无法将For循环中找到的数据粘贴到同一工作表上不同范围的下一个可用行中。我想要粘贴的范围是(“A295:A324”)。我只使用一张纸(“打印输出”),而不是任何其他纸张。他就是我到目前为止所拥有的
Sub CmpnyWkLoad_autofil()
lr = 338 'last row
lc = 69 'last column
For r = 332 To lr 'start at row 332
current = False
For c = 60 To lc 'start at column BH
If Cells(r, c).Value >= Range("V4").Value Then current = True: Exit For
Next c
If current Then Columns("A:AG").Rows(r).Copy
Next r
End Sub
我正在循环/读取的是列中的预填充日期(“BH:BQ”),如果它们在今天的日期之后,它将同一行中的前33个cols复制并粘贴到下一个可用行中(“A295:A324”)然后继续循环结束。任何帮助完成这一点将非常感激。
答案 0 :(得分:0)
如果我在评论中的假设是正确的,你可以试试这个:
Dim lr As Long, cel As Range
With Thisworkbook.Sheets("PrintOut")
'~~> Check up to where your last row in BH is
lr = .Range("BH" & .Rows.Count).End(xlUp).Row '~~> you can also use lr = 338
'~~> You said BH row starts at 332
For i = 332 To lrow
For Each cel In .Range("BH" & i, "BQ" & i)
If cel.Value >= .Range("V4").Value Then
.Range("A" & cel.Row, "AG" & cel.Row).Copy
.Range("A" & .Rows.Count).End(xlUp) _
.Offset(1, 0).PasteSpecial xlPasteValues, , , True
Exit For
End If
Next
Next
End With
HTH