excel 如果此单元格= 0,如何添加跳过并转到下一步

ivqmmu1c  于 2023-01-21  发布在  其他
关注(0)|答案(1)|浏览(374)

我有一些东西,将自动为我生产的东西,但我想如果这个单元格是= 0后,运行选择帐户,然后跳过,不生产

Sub AutoMakeInv()

    Dim lPrefix As Long
    Dim lCount As Long
    Dim Account_Number As String

    For lPrefix = 1 To 14
        For lCount = 1 To 2000
            Account_Number = "F" & Format(lPrefix, "00") & " " & Format(lCount, "0000")
            Debug.Print Account_Number
            Cells(8, 5).Value = Account_Number
            Call SelectAcct
            Call ProduceInv
            ' Do something ...
        
        Next lCount
    Next lPrefix

End Sub
k4emjkb1

k4emjkb11#

这将检查一个单元格是否为0,如果不为0,则只运行另外两个子程序:

Option Explicit
Sub AutoMakeInv()

    Dim lPrefix As Long
    Dim lCount As Long
    Dim Account_Number As String

    For lPrefix = 1 To 14
        For lCount = 1 To 2000
            Account_Number = "F" & Format(lPrefix, "00") & " " & Format(lCount, "0000")
            Debug.Print Account_Number
            Cells(8, 5).Value = Account_Number
            If Not Range("INSERT YOUR CELL ADDRESS").Value = 0 Then
                Call SelectAcct
                Call ProduceInv
            End If
        Next lCount
    Next lPrefix

End Sub

相关问题