Rotate image if cell ends with "B"

chris186h

Board Regular
Joined
Mar 18, 2015
Messages
111
Hello all.
I have found a few articles but nothing that really matches what im trying to acheive.
I would like if B2 end with the letter B then shape "Up Arrow 1" rotates to 180 degrees elsewise keep at 0 degrees.
Any help would be greatly appreciated.
 

Some videos you may like

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

gallen

Well-known Member
Joined
Jun 27, 2011
Messages
1,996
Here is the code:
Code:
    If UCase(Right(Range("B2"), 1)) = "B" Then
         Me.Shapes("Up Arrow 1").Rotation = 180
    Else
         Me.Shapes("Up Arrow 1").Rotation = 0
    End If
Or a neater way would be:

Code:
Me.Shapes("Up Arrow 1").Rotation = IIf(UCase(Right(Range("B2"), 1)) = "B", 180, 0)
 

chris186h

Board Regular
Joined
Mar 18, 2015
Messages
111
Here is the code:
Code:
    If UCase(Right(Range("B2"), 1)) = "B" Then
         Me.Shapes("Up Arrow 1").Rotation = 180
    Else
         Me.Shapes("Up Arrow 1").Rotation = 0
    End If
Or a neater way would be:

Code:
Me.Shapes("Up Arrow 1").Rotation = IIf(UCase(Right(Range("B2"), 1)) = "B", 180, 0)
That worked perfectly. Thankyou very much for your help
 

Watch MrExcel Video

Forum statistics

Threads
1,100,209
Messages
5,473,177
Members
406,850
Latest member
gustavor0

This Week's Hot Topics

Top