vba - 在 for 循环中跳过迭代(VBA excel)

标签 vba excel

我有一段代码,我希望 for 循环继续到 i 的下一个值如果单元格中的值为"nil"并且不执行循环中的命令。我无法弄清楚。

For i = 2 To n
    If .Cells(i, "G").Value = "nil" Then
        next i
    Else
        mon = month(.Cells(i, "G").Value)
        acctyp = .Cells(i, "P").Value
    end if
next i

提前致谢。

最佳答案

comparison operator <>表示“不等于”:

For i = 2 To n
    If .Cells(i, "G") <> "nil" Then
        mon = Month(.Cells(i, "G"))
        acctyp = .Cells(i, "P")
    End If
Next i

关于vba - 在 for 循环中跳过迭代(VBA excel),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52474677/

相关文章:

excel - 横向另存为 PDF

Excel用 "lookup"(工作表B)中的相应字符串替换单元格(工作表A)中的子字符串

Excel VBA : how to find the first row number of the Page1

vba - Excel:使用 VBA 获取单元格的背景颜色

excel - 调用 Form.Show vbmodeless 时,VBA 表单(自动)绑定(bind)/绑定(bind)到 ActiveWorksheet

vba - 配置作业编号以包含前缀、年、月和下一个序号

vba - 将数字字符转换为字母字符

vba - 如何使VBA代码与Office 2010兼容-64位版本和较旧的Office版本

excel - VBA 应用程序定义的错误 Outlook 连接

C#:从 Excel 公式中读取值