gpt4 book ai didi

VBA:对于 wRange 中的每个 wCell

转载 作者:行者123 更新时间:2023-12-04 20:40:56 24 4
gpt4 key购买 nike

我遇到了 For Each 循环的问题。

我正在尝试使用循环:

wRange = Range(Cells(5, countryCol), Cells(lastrow, countryCol))
For Each wCell In wRange
If wCell = "Unknown" Then
wCell.Offset(0, 3).Value = "Follow up with receiving"
wCell.Offset(0, followUp - countryCol) = "Send to receiving"
End If
Next

当我将变量定义为:
Dim wRange As Range
Dim wCell As Range

我收到运行时错误 Object variable or With block variable not set在线上
wRange = Range(Cells(5, countryCol), Cells(lastrow, countryCol))
当我将变量定义为:
Dim wRange, wCell As Range
我收到一个运行时错误: Object required在线上
For Each wCell In wRange
如果我像这样使用循环
For Each cell In wRange
If cell = "Unknown" Then
cell.Offset(0, 3).Value = "Follow up with receiving"
cell.Offset(0, followUp - countryCol) = "Send to receiving"
End If
Next

我收到运行时错误 Object required在线上
cell.Offset(0, 3).Value = "Follow up with receiving"

最佳答案

如对原始问题的评论所述,我需要使用 Set

Set wRange = Range(Cells(5, countryCol), Cells(lastrow, countryCol))
For Each wCell In wRange
If wCell = "Unknown" Or wCell = "" Then
wCell.Offset(0, reviewStatus - countryCol).Value = "Follow up with receiving"
wCell.Offset(0, followUp - countryCol) = "Send to receiving"
End If
Next

关于VBA:对于 wRange 中的每个 wCell,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33738874/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com