我想复制和粘贴包括空白单元格到另一个单一列中的范围。我希望空白被忽略。范围与空白单元格复制并粘贴到单个列
这里是怪人的代码我使用此刻却是缓慢的,有点cluncky picture included to better describe
我想它扩大使多个范围可以粘贴到同一列,即找到最后一个单元格一个值并粘贴到下一个单元格中。
有人告诉我,它应该是这个样子
'for r = 1 to 4
' for c = 1 to 8
' does rc have val,
' then copy to new sheet
' increment copy var
' increment c
' increment r
Sheets(Array("next record date")).Select
Range("G11:AZZ110").Select
If TypeName(Selection) = "Range" Then
If Selection.Count > 1 Then
If Selection.Count <= Selection.Parent.Rows.Count Then
vaCells = Selection.Value
ReDim vOutput(1 To UBound(vaCells, 1) * UBound(vaCells, 2), 1 To 1)
For j = LBound(vaCells, 2) To UBound(vaCells, 2)
For i = LBound(vaCells, 1) To UBound(vaCells, 1)
If Len(vaCells(i, j)) > 0 Then
lRow = lRow + 1
Sheets("Data").Select
Range("E2").Select
vOutput(lRow, 1) = vaCells(i, j)
Else
End If
Next i
Next j
Selection.ClearContents
Selection.Cells(1).Resize(lRow).Value = vOutput
End If
End If
结束如果
感谢,
杰罗姆
嗨,您的源数据和期望的输出的图像将会有所帮助。并且不要使用.select。你将能够使用With语句,并且如果仅从一张纸复印(尽管这可能是我挑剔),你也不需要纸张数组。另外,为什么如果TypeName(Selection)=“Range”那么?您刚刚选择了范围。有没有可能因为某些原因你不能选择它? – QHarr