VBA,如果跳过单元格

标签 vba excel

我想遍历我的范围并合并如果 B2:B100 为“否”则跳过的逻辑。

原始代码:

 Dim cell As Range
    For Each cell In Range("A2:A100")
        FilePaths.Add cell.Value
    Next cell

试:
If cell.Range("B2:B100") <> "Yes" Then

不知道下一步要去哪里。我想去 col A 的下一个单元格,或者继续回到 col A。

最佳答案

使用 Offset指向 Range在给定的行和/或列与引用的偏移量

Dim cell As Range
For Each cell In Range("A2:A100")
    If cell.Offset(0, 1).Value2 <> "NO" Then FilePaths.Add cell.Value2
Next cell

关于VBA,如果跳过单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51861536/

相关文章:

vba - Excel 中工作表的自动完成代码在使用 VB 的其他工作表中不起作用

vba - 动态设置 CommandBar "Popup"子菜单图标

excel - VBA - 如何使 For 循环更快

vba - "<Application-defined or object-defined error> Error 1004"

excel - 无法在 Excel 中将日期字符串转换为日期值

c# - 将 DataTable 导出到 Excel 删除换行符

Excel 带条件的非重复计数

c# - 寻求 Excel 自定义函数工具提示

excel - 空的替换为0

arrays - VBA 停止使用临时范围