我很新的VBA和我想要在这里做的可能是完全疯狂,但请温柔与我:-)如果在for循环
所以有点背景的陈述。我有一个项目清单(TLD)和价目表。使用下面的代码,如果项目的名称,产品和期限是正确的(我希望这是有道理的),我试图从每个项目的价格表中扣除价格。
当我运行它,我得到 “编译错误:否则没有如果”
Sub add_prices()
Dim startnumber As Long
Dim endnumber As Long
Dim TLD As String
Dim Listtld As String
endnumber = Sheets("Pricelist").Application.WorksheetFunction.CountF(Range("F2:F40000")) - 1
For startnumber = 0 To endnumber
TLD = Cells(3 + startnumber, 2)
Listtld = Sheets("pricelist").Cells(2 + startnumber, 7)
Product = Sheets("pricelist").Cells(2 + startnumber, 8)
Period = Sheets("pricelist").Cells(2 + startnumber, 9)
If TLD = Listtld Then
If Product = "auto renewal" Then
If Period = "1 year" Then
Cells(3 + startnumber, 3).Value = Sheets("pricelist").Cells(2 + startnumber, 2)
Else
If Period = "2 years" Then
Cells(3 + startnumber, 3).Value = Sheets("pricelist").Cells(3 + startnumber, 2)
End If
Else
If Period = "3 years" Then
Cells(3 + startnumber, 3).Value = Sheets("pricelist").Cells(4 + startnumber, 2)
End If
Else
If Period = "4 years" Then
Cells(3 + startnumber, 3).Value = Sheets("pricelist").Cells(5 + startnumber, 2)
End If
Else
If Period = "5 years" Then
Cells(3 + startnumber, 3).Value = Sheets("pricelist").Cells(6 + startnumber, 2)
End If
End If
End If
End If
Next startnumber
End Sub
任何建议,将不胜感激
同时删除结束时,如果在内部,如果的 –