Color the shapes based on cell value usingfor loop

wasantha

New Member
Joined
May 20, 2015
Messages
1
I want to color the shape based on cell value. for this i have used if condition and it work correctly but issue is there are more shapes and when i used if function error appeared as a " Procedure too large " i want to eliminate that.

After i have used for loop but it not meet the my requirement. Pls share any one know this. below is the for loop cording

Sub RoundedRectangle1_Click()
Dim i As Integer
For i = 1 To 5
If Range("B4").Value = i Then
ActiveSheet.Shapes("Smiley Face 77").Fill.ForeColor.SchemeColor = 3
ActiveSheet.Shapes("Smiley Face 78").Fill.ForeColor.SchemeColor = 3
ActiveSheet.Shapes("Smiley Face 79").Fill.ForeColor.SchemeColor = 3
ActiveSheet.Shapes("Smiley Face 80").Fill.ForeColor.SchemeColor = 3
ActiveSheet.Shapes("Smiley Face 81").Fill.ForeColor.SchemeColor = 3
ActiveSheet.Shapes("Smiley Face 82").Fill.ForeColor.SchemeColor = 3
ActiveSheet.Shapes("Smiley Face 83").Fill.ForeColor.SchemeColor = 3
End If

Next i
End Sub
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple

Forum statistics

Threads
1,203,068
Messages
6,053,344
Members
444,654
Latest member
Rich Cohen

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top