• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Use If Then based on cell value

Junarkar

Member
Hi

Below is my code which will create a fill effect to a wordart;

>>> use code - tags <<<
Code:
If wsDFD.Range("F34").Value <> olval Then
        With Shapes("Rectangle 58").TextFrame2.TextRange.Font.Fill
            .TwoColorGradient msoGradientHorizontal, 1
            .GradientAngle = 270
            .GradientStops(1).Color = RGB(79, 129, 189)
            .GradientStops(1).Position = wsDFD.Range("F34").Value
            .GradientStops(2).Color = RGB(166, 166, 166)
            .GradientStops(2).Position = wsDFD.Range("F34").Value
        End With
End If
This gives below fill effect to the wordart;

69495

My problem starts when the value of the cell goes beyond 100%. Then VBA will show error. Can there be a If Then statement which helps to restrict the Gradient position to 100% even if the cell value is >100%. If cell value is <100% then it should take value from cell itself.

Please help.

Regards
Junarkar
 
Last edited by a moderator:
  • Like
Reactions: Hui
Top