2012-02-09 59 views

回答

2

試試這個:

With Intersect(Columns("G:G"), ActiveSheet.UsedRange) 
    If WorksheetFunction.CountBlank(.Cells) > 0 Then 
     .SpecialCells(xlCellTypeBlanks).Offset(, -6).ClearContents 
    End If 
End With 
+0

+1不錯的使用COUNTBLANK而不是標準的錯誤檢查 – brettdj 2012-02-09 00:37:13

0

試試這個。

Columns("G:G").SpecialCells(xlCellTypeBlanks).Offset(0,-6).ClearContents 
0

像這樣:

On Error Resume Next  ' In case there are no blanks 
Columns("G:G").SpecialCells(xlCellTypeBlanks).Offset(, -6) = "" 
+1

如果你要訴諸錯誤處理(出錯時繼續下一步),不要忘了之後重置(On Error轉到0) – Reafidy 2012-02-09 00:27:44

相關問題