麻烦嵌套if ..然后在Excel 2010的循环中

use*_*097 2 excel for-loop if-statement nested

我道歉,如果这是一个简单的问题,我刚开始的宏编程较昨日QBASIC(或一会儿任何语言)还没有Basic编写的.我特林读变量是否等于一个特定的值,如果是这样,写不同的细胞到电子表格中,如果它包含的数据.没有for,我一直得到下一个错误.没有第一个if声明它运行良好,有人可以帮助我吗?奖金,如果你可以帮助写出价值而不是内容,但我可以解决这个问题,而不会打扰你们.感谢帮助我达到这一点,这个网站非常宝贵.你可能会认识到一些编码.

Sub B920LOI()

x = 5 iMaxRow = 3000

对于iRow = 3到iMaxRow

If Sheets("Sheet2").Cells(iRow, "B") = "B920" Or Sheets("Sheet2").Cells(iRow, "B") = " B920" Then



    If Sheets("Sheet2").Cells(iRow, "K") > 35 And Sheets("Sheet2").Cells(iRow, "K") < 55 Then

    ' Check that cell is not empty.
    ' Copy the cell to the destination
    With Worksheets("Sheet2").Cells(iRow, "K")
    .Copy Destination:=Worksheets("920 LOI").Cells(x, "B")

    End With

    x = x + 1


    Else
        'Nothing in this cell.
        'Do nothing.

    End If

Else
        'Nothing in this cell.
        'Do nothing.

End If
Run Code Online (Sandbox Code Playgroud)

下一个iRow

结束子

这是"工作版"谢谢.

Joe*_*sky 7

你的巢必须匹配......"End With"需要在With所在的If块内.