×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Frustrated with If then else statement

Frustrated with If then else statement

Frustrated with If then else statement

(OP)
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]

RE: Frustrated with If then else statement

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

RE: Frustrated with If then else statement

(OP)
Thanks,
I found it.  I appreciate the help.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources