麻烦嵌套如果..然后在Excel 2010中循环

我很抱歉,如果这是一个容易的问题,我刚刚开始macros编程昨天,并没有写在BASIC以来,因为qBasic(或任何语言一段时间)。 我试图读取一个variables是否等于一个特定的值,如果是,写入一个不同的单元格,如果它包含数据的电子表格。 我不断地收到一个错误。 它运行良好没有第一个如果声明,有人可以帮我吗? 如果你可以帮助写作的价值而不是内容的奖金,但我可以弄清楚,而不打扰你罚款人。 感谢帮助到这一点,这个网站是非常宝贵的。 你可能会认识到一些编码。

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 

下一个iRow

结束小组

这是“工作版”谢谢。

你的巢穴必须匹配…“结束”需要在With的If块内。