Hi folks,
I have a simplified timeline example in the attached image below to illustrate what I am trying to do. For some reason XL2bb isn't working for me to put the mini-sheet in.
I've been trying to work out the code, but can't get things to work, for example For Each can't loop through my rows so I'm not sure how else to loop through each row, then each shape.
I have a simplified timeline example in the attached image below to illustrate what I am trying to do. For some reason XL2bb isn't working for me to put the mini-sheet in.
- With a macro, I would like to recolor any shape that is in a row marked with an "assign color" (C2:C6) entry.
- I already can manage the RGB color using this snippet so mainly I'm trying to figure out the syntax to loop through the rows and shapes.
VBA Code:
Set s = ws.Shapes.AddShape(Type:=msoShapeRectangle, _
Left:=c.Left, _
Top:=c.Top, _
Width:=c.Width + Dur, _
Height:=c.Height)
s.Fill.ForeColor.RGB = RGB(R, G, B)
I've been trying to work out the code, but can't get things to work, for example For Each can't loop through my rows so I'm not sure how else to loop through each row, then each shape.
VBA Code:
Sub ReColorShape()
Dim nRow As Long
Dim R, G, B As Integer
R = 255
G = 145
B = 192
With ActiveSheet
nRow = .Cells.SpecialCells(xlCellTypeLastCell).Row 'throws error about only being able to loop over collection or group object
Do Until nRow = 1
For Each shp In ActiveCell.Row
Set s = ws.Shapes.ActiveShape 'or should it be =ActiveSheet.Shapes ?
s.Fill.ForeColor.RGB = RGB(R, G, B)
Next shp
nRow = nRow - 1
Loop
End With
End Sub