D. Jay
D. Jay

Reputation: 13

Populating Cells with VBA

There is something going wrong below but I can't work out what. Everything populates except the last two If statements. I am not getting any errors from excel, it just doesn't populate.

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

Upvotes: 0

Views: 817

Answers (1)

Joshua Fenner
Joshua Fenner

Reputation: 355

With the lack of End If everything is chained to whether or not NTC.Region.Value = "China"

Try This:

'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"

Upvotes: 2

Related Questions