Excel VBA help

KarmaStrikesBack

Supremacy Member
Joined
Mar 24, 2016
Messages
8,975
Reaction score
7
I have 2 shapes, 1 and 2.

My code is

If ActiveSheet.Shapes(“Shape 1”).Fill.ForeColor.RGB = RGB(0, 255, 0) Then
ActiveSheet.Shapes(“Shape 2”).Fill.ForeColor.RGB = RGB(255, 0, 0)
Else
ActiveSheet.Shapes(“Shape 2”).Fill.ForeColor.RGB = RGB(255, 255, 255)
End If
End Sub


However, i do not know how the code should start.

Whatever colour i changed Shape 1 to, Shape 2 does nothing. I have tried
sub worksheet_change(byval as blah blah blah)


 

davidktw

Arch-Supremacy Member
Joined
Apr 15, 2010
Messages
13,547
Reaction score
1,301
I have 2 shapes, 1 and 2.

My code is

If ActiveSheet.Shapes(“Shape 1”).Fill.ForeColor.RGB = RGB(0, 255, 0) Then
ActiveSheet.Shapes(“Shape 2”).Fill.ForeColor.RGB = RGB(255, 0, 0)
Else
ActiveSheet.Shapes(“Shape 2”).Fill.ForeColor.RGB = RGB(255, 255, 255)
End If
End Sub


However, i do not know how the code should start.

Whatever colour i changed Shape 1 to, Shape 2 does nothing. I have tried
sub worksheet_change(byval as blah blah blah)



This might interest you :)

F9TUs1t.mp4


Code:
Sub Button1_Click()
    Rem Debug.Print ActiveSheet.Shapes.Count
    For i = 1 To ActiveSheet.Shapes.Count
        ActiveSheet.Shapes(i).Name = "Shape " & i
        Rem ActiveSheet.Shapes(i).Fill.ForeColor.RGB = RGB(0, 0, 255)
        ActiveSheet.Shapes(i).Fill.ForeColor.RGB = RGB(Int(Rnd() * 256), _
                                                       Int(Rnd() * 256), _
                                                       Int(Rnd() * 256))
    Next i
End Sub
 
Last edited:

davidktw

Arch-Supremacy Member
Joined
Apr 15, 2010
Messages
13,547
Reaction score
1,301
Important Forum Advisory Note
This forum is moderated by volunteer moderators who will react only to members' feedback on posts. Moderators are not employees or representatives of HWZ Forums. Forum members and moderators are responsible for their own posts. Please refer to our Community Guidelines and Standards and Terms and Conditions for more information.
Top