使用VBA填充单元格

时间:2017-10-03 04:00:41

标签: vba excel-vba excel

下面有一些问题,但我无法解决问题。除最后两个If语句外,所有内容都会填充。我没有从excel得到任何错误,它只是没有填充。

If NTC.Region.Value = "China" Then
Sheet1.Cells(87, 6).Value = "N/A"
Sheet1.Cells(88, 6).Value = "N/A"

If NTC.RAR.Value = "No" Then
Sheet1.Cells(94, 6).Value = "N/A"

If NTC.Rate1.Value = "Floating" Then
Sheet1.Cells(75, 6).Value = "N/A"

End If

1 个答案:

答案 0 :(得分:2)

由于缺少End If,所有内容都与NTC.Region.Value = "China"

相关联

试试这个:

'create a block if because you want to do more than 1 thing
If NTC.Region.Value = "China" Then
    Sheet1.Cells(87, 6).Value = "N/A"
    Sheet1.Cells(88, 6).Value = "N/A"
End if

'Changed to 1 line if statement
If NTC.RAR.Value = "No" Then Sheet1.Cells(94, 6).Value = "N/A"

'Changed to 1 line if statement
If NTC.Rate1.Value = "Floating" Then Sheet1.Cells(75, 6).Value = "N/A"