我想複製和粘貼包括空白單元格到另一個單一列中的範圍。我希望空白被忽略。範圍與空白單元格複製並粘貼到單個列
這裏是怪人的代碼我使用此刻卻是緩慢的,有點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