【发布时间】:2018-07-12 10:23:14
【问题描述】:
我想检查 D 到 O 列中的所有单元格。如果单元格为空,请将其替换为硬零。
我有这个代码:
Sub replace()
Dim rng As Range, cell As Range
Dim aantalrijen As Long
With Worksheets("Schaduwblad")
aantalrijen = .Range("A1", .Range("A1").End(xlDown)).Cells.Count - 1
Set rng = .Range(.Cells(2, "D"), .Cells(aantalrijen, "O"))
For Each cell In rng
cell = WorksheetFunction.Substitute(cell, "", "0")
Next
End With
End Sub
此代码在处理过程中挂起。唯一的选择是按 Escape 键结束例程。
【问题讨论】:
-
你不能使用查找和替换来完全避免循环吗?
-
否,因为数据在隐藏的工作表上,并且每 4 周返回一次。
标签: excel vba substitution