问问题
5469 次
2 回答
1
简单 - 只需稍微编辑 Else 语句...
' Loop through columns and rows
For iCol = 1 To 3 ' or however many columns you have
For iRow = 1 To iMaxRow
With Worksheets("Sheet1").Cells(iRow,iCol)
' Check that cell is not empty.
If .Value = "" Then
'Nothing in this cell.
'Do nothing.
Else
' Copy the cell to the destination
Worksheets("Sheet2").cells(iRow,iCol).value = .value
End If
End With
Next iRow
Next iCol
希望这就是你的意思......
于 2012-11-12T20:59:22.230 回答
1
要将所有单元格从Sheet1列的已用部分复制A:C
到Sheet2作为您可以使用的值
无论如何复制时,空白单元格将是空白的。
Sub Better()
Dim ws As Worksheet
Set ws = Sheets("Sheet1")
Set rng1 = ws.Range(ws.[a1], ws.Cells(Rows.Count, "A").End(xlUp))
Sheets("Sheet2").Range(rng1.Address).Value = rng1.Value
End Sub
于 2012-11-12T22:51:27.513 回答