Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Frustrated with If then else statement

Status
Not open for further replies.

jskintner

Bioengineer
Dec 12, 2006
2
I'm having a problem getting a If Then Else statement to work. All it needs to do is change the font color of a certain cell based on a comparison of the result of a formula in the cell to experience color change with the value of a scroll bar.


I know I'm close, but I just can't quite get it. I'm now getting a 424 run time error.

I'd appreciate any help offered.

Here's my current code. This was supposed to be a quick Macro, but is turning into a headache.

[Private Sub ScrVehiclePrice_Change()
Range("C4") = ScrVehiclePrice.Value

If MonthlyPayment.Value > ScrMaxPayment.Value Then
Range("C9").Font.Color = RGB(255, 0, 0)
Else
Range("C9").Font.Color = RGB(0, 0, 0)
End If
End Sub]
 
Replies continue below

Recommended for you

There is nothing wrong with your posted code, per se. I mocked this up and it worked as expected. The error you are getting indicates a problem with an object declaration/reference. I don't know what the rest of your worksheet and code looks like but my best guess is that MonthlyPayment is supposed to reference a worksheet control; a TextBox perhaps. If so, check to see that you renamed it after adding it to the sheet so that it is the same as in your code.

Regards,
Mike
 
Thanks,
I found it. I appreciate the help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor