嗨,谢谢你提前
我正在开发一个vba,当一个特定值输入到范围内的单元格中时,将行从一个工作表复制并粘贴到另一个工作表中。" O"。
目前我的vba工作正常,但我希望它从A列复制到Z而不是整行。
请参阅下面我的当前代码:
Dim xRg As Range
Dim xCell As Range
Dim I As Long
Dim J As Long
Dim K As Long
I = Worksheets("Demand Log").UsedRange.Rows.Count
J = Worksheets("Change Log").Cells(Worksheets("Change Log").Rows.Count, "B").End(xlUp).Row
If J = 1 Then
If Application.WorksheetFunction.CountA(Worksheets("Change Log").Range) = 0 Then J = 0
End If
Set xRg = Worksheets("Demand Log").Range("O5:O" & I)
On Error Resume Next
Application.ScreenUpdating = False
For K = 1 To xRg.Count
If CStr(xRg(K).Value) = "Change Team" Then
J = J + 1
xRg(K).EntireRow.Copy Destination:=Worksheets("Change Log").Range("A" & J)
xRg(K).EntireRow.Delete
End If
Next
Application.ScreenUpdating = True
答案 0 :(得分:1)
使用Resize方法。顺便说一下,当删除行时总是向后循环,否则你会错过行。
Cells(xRg(K).row,1).Resize(,26).Copy Destination:=Worksheets("Change Log").Range("A" & J)
答案 1 :(得分:1)
删除要从下到上的行时。
您可以使用Intersect:
o.groupBy(player.getName())
.flatMap(namePlayers -> {
// How can I extract Observable<Player> from namePlayers
// I want to write sth like this:
.collect(Result::new, (result, player) -> result.mergeInfoFrom(player))
.flatMapCompletable(result -> writeResultSomeWhere())
}