我在代码中犯了一个错误,我写了.FormulaR1C1 = ""
而不是.Value = 0
。
我在代码中写了很多错误,我想修复它。
有没有办法告诉excel,无论他在哪里找到组合.value = 0
并将其更改为.FormulaR1C1 = ""
?
如果没有,是否有办法搜索组合.value = 0
,所以我可以手动更改它?
答案 0 :(得分:0)
Yoni,如上所述,您需要将 0 替换为空字符串...
Sub AdjustZeroCells()
Dim ws As Worksheet
Dim cell As Range
'sets worksheet variable
Set ws = ThisWorkbook.Worksheets("Sheet1")
'only loops through cells with formulas
For Each cell In ws.UsedRange.SpecialCells(xlCellTypeFormulas)
If cell.Value = 0 Then: cell.Value = ""
Next cell
'cleanup
Set cell = Nothing: Set ws = Nothing
End Sub
丹尼, ExcelVBADude