【发布时间】:2017-03-02 10:02:32
【问题描述】:
我有一个这样的电子表格:
Column D Column G
1 #VALUE!
2 #VALUE!
#VALUE! 3
我正在尝试在我的范围内搜索值 #VALUE!。
在哪里找到这个值,我想更改每次出现的#VALUE!待定。
这是我的代码:
Range("D30:G39").Select
Set cell = Selection.Find(What:="#VALUE!", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
If cell Is Nothing Then
'do it something
Else
For Each Cell.Value
cell.value = "TBC"
Next Cell
'End For
wStemplaTE.Range("A41").value = "Please fill in the pallet factor and case size accordingly. Please amend total volume if necessary to accommodate full pallets."
End If
我需要尝试创建一个循环,以便将每个单元格值更改为 TBC。
我是 VBA 的新手,不太确定该怎么做。
请有人指出我正确的方向/告诉我如何正确地做到这一点?谢谢
编辑:
For Each Cell.Value
【问题讨论】:
-
试试看 xlPart
-
为什么不使用查找和替换?
-
@Nathan_Sav : 不,这里的问题是
LookIn:=xlFormulas,但应该是xlValues -
我写了
Cells.Find(What:="#ref", After:=ActiveCell, LookIn:=xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= False, SearchFormat:=False)并且工作正常 -
@Nathan_Sav 你能告诉我你为这行写了什么:For Each Cell.Value?此行表示格式不正确并突出显示红色