我想引用所有非空单元格。到目前为止,我最好的尝试是:
ActiveSheet.SpecialCells(Not(xlCellTypeBlanks)).NumberFormat = "General"
但它不起作用。你知道怎么让这个工作吗?
答案 0 :(得分:0)
尝试一下:
Sub cutaneous()
Dim rNonEmpty As Range
Dim rEmpty As Range, r As Range
Set rEmpty = Cells.SpecialCells(xlCellTypeBlanks)
Set rNonEmpty = Nothing
For Each r In ActiveSheet.UsedRange
If Intersect(r, rEmpty) Is Nothing Then
If rNonEmpty Is Nothing Then
Set rNonEmpty = r
Else
Set rNonEmpty = Union(r, rNonEmpty)
End If
End If
Next r
rNonEmpty.NumberFormat = "General"
MsgBox rNonEmpty.Address
End Sub