移动单元格值和删除行
Moving cell values and deleting rows
我需要移动一些数据,但我当前的代码(从 vba 几周开始,所以请仁慈 :) )超级慢。
你能给我一些建议吗?
我想从这个...
...到此...
...然后是这个。
Do While Not Listado.Cells(rowquery, colquery) = ""
Listado.Cells(rowquery, colquery).Offset(0, 2) = Listado.Cells(rowquery, colquery).Offset(1, 1)
Listado.Cells(rowquery, colquery).Offset(0, 3) = Listado.Cells(rowquery, colquery).Offset(2, 1)
Listado.Cells(rowquery, colquery).Offset(1, 1).Clear
Listado.Cells(rowquery, colquery).Offset(2, 1).Clear
rowquery = rowquery + 3
Loop
谢谢!
速度很慢,因为您一直在访问工作表。甚至可能有引用正在移动和清除的单元格的公式。
在变体数组中工作并将数据转储回工作表,然后删除第一列中的重复项。
dim i as long, arr as variant
arr = Listado.databodyrange.value2
for i=lbound(arr, 1) to ubound(arr, 1) step 3
arr(i, 3) = arr(i+1, 2)
arr(i, 4) = arr(i+2, 2)
arr(i+1, 2) = vbnullstring
arr(i+2, 2) = vbnullstring
next i
Listado.databodyrange = arr
我需要移动一些数据,但我当前的代码(从 vba 几周开始,所以请仁慈 :) )超级慢。
你能给我一些建议吗?
我想从这个...
...到此...
...然后是这个。
Do While Not Listado.Cells(rowquery, colquery) = ""
Listado.Cells(rowquery, colquery).Offset(0, 2) = Listado.Cells(rowquery, colquery).Offset(1, 1)
Listado.Cells(rowquery, colquery).Offset(0, 3) = Listado.Cells(rowquery, colquery).Offset(2, 1)
Listado.Cells(rowquery, colquery).Offset(1, 1).Clear
Listado.Cells(rowquery, colquery).Offset(2, 1).Clear
rowquery = rowquery + 3
Loop
谢谢!
速度很慢,因为您一直在访问工作表。甚至可能有引用正在移动和清除的单元格的公式。
在变体数组中工作并将数据转储回工作表,然后删除第一列中的重复项。
dim i as long, arr as variant
arr = Listado.databodyrange.value2
for i=lbound(arr, 1) to ubound(arr, 1) step 3
arr(i, 3) = arr(i+1, 2)
arr(i, 4) = arr(i+2, 2)
arr(i+1, 2) = vbnullstring
arr(i+2, 2) = vbnullstring
next i
Listado.databodyrange = arr