我创建了以下代码,它的目的是删除数据之间存在的R列中的空单元格,问题是如何在范围内存储空白单元格,有什么建议吗?
Sub Macro1()
Dim lastRow_1 As Long
Dim counter_1 As Long
Dim rng_1 As Range, aCell As Range
lastRow_1 = Range("R" & Rows.Count).End(xlUp).Row
MsgBox lastRow_1
counter_1 = 1
For counter_1 = 1 To lastRow_1
If Trim(Range("R" & counter_1).Value) = "" Then
Set aCell = Range("R" & counter_1)
rng_1 = Union(rng_1, aCell)
End If
Next
rng_1.Delete xlUp
End Sub
答案 0 :(得分:1)
假设R200是范围内的最后一个单元格
range("R1:R200").SpecialCells(xlCellTypeBlanks).Delete