顯示廣告
隱藏 ✕
看板 Mesak
作者 mesak (Mesak)
標題 [VBA] 清除空白資料
時間 2015-08-14 Fri. 16:20:36


Sub ClearEmpty()

Application.Calculation = xlCalculationManual   '手動
Dim c As Range
Dim r As Range

'Set r = Range("H2:HF1000")
'Set r = Range("H500:HF1000")
Set r = Selection
Set r = r.SpecialCells(xlCellTypeConstants, xlTextValues)

Debug.Print r.Count

If r.Count > 0 Then
    For Each c In r
        'Debug.Print c.Address
        If Len(c) = 0 Then c.ClearContents
    Next c
    Debug.Print "OK"
End If

Application.Calculation = xlCalculationAutomatic    '自動
End Sub

--
※ 作者: mesak 時間: 2015-08-14 16:20:36
※ 編輯: mesak 時間: 2015-08-14 17:52:45
※ 看板: Mesak 文章推薦值: 0 目前人氣: 0 累積人氣: 223 
r)回覆 e)編輯 d)刪除 M)收藏 ^x)轉錄 同主題: =)首篇 [)上篇 ])下篇