Sub usedrange行列()
Dim Col_Count As Long
With ActiveSheet.UsedRange
For Col_Count = .Columns.Count To 1 Step -1
If WorksheetFunction.CountA(.Item(1).Resize(1, .Columns.Count)(Col_Count).EntireColumn) = 0 Then
.Item(1).Resize(1, .Columns.Count)(Col_Count).EntireColumn.Delete
End If
Next
End With
Dim Row_Count As Long
With ActiveSheet.UsedRange
For Row_Count = .Rows.Count To 1 Step -1
If WorksheetFunction.CountA(.Item(1).Resize(.Rows.Count, 1)(Row_Count).EntireRow) = 0 Then
.Item(1).Resize(.Rows.Count, 1)(Row_Count).EntireRow.Delete
End If
Next
End With
With ActiveSheet.UsedRange
MsgBox "已用的区域地址为:" & .Address & Chr(13) & "最大行为:" & .Rows.Count & Chr(13) & "最大列为:" & .Columns.Count _
& Chr(13) & "共有单元格数:" & .Cells.Count & Chr(13) & "第一行为:" & .Item(1, 1).Row & Chr(13) & "第一列为:" & .Item(1, 1).Column