0

I want to reference all non-empty cells. My best attempt so far is:

ActiveSheet.SpecialCells(Not(xlCellTypeBlanks)).NumberFormat = "General"

But it doesn't work. Do you know how I can get this to work?

4

1 回答 1

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
于 2013-09-01T13:28:31.700 回答