Multiple Shape Color at the same time.

richie247

New Member
Joined
Feb 3, 2017
Messages
17
Office Version
  1. 365
  2. 2013
Platform
  1. Windows
i have been running this code which works well however sometimes there is a overlap of the times, for each shape. ideally I want it to show 2 or more colours depending if there is multiple true cases. Hopefully there is someone who knows if this can be done.

Sub ShowHideAreas()
Dim sh1 As Worksheet, sh2 As Worksheet, i As Long, j As Long
Dim wRGB As Variant, shp As Object
'
Set sh1 = Sheets("Sheet1")
Set sh2 = Sheets("Sheet2")
'
sh1.Select
For Each shp In sh1.Shapes
If LCase(Left(shp.Name, 6)) = LCase("Area_A") Then
shp.Visible = False
End If
Next
'
For i = 2 To sh2.Range("C" & Rows.Count).End(xlUp).Row
For j = 1 To 52
If sh2.Cells(i, Columns("G").Column + j - 1).Value = True Then
sh1.Shapes.Range(Array("Area_A" & j)).Visible = True
Select Case sh2.Range("C" & i)
Case "number 1": wRGB = RGB(255, 204, 153)
Case "number 2": wRGB = RGB(255, 255, 0)
Case "number 3": wRGB = RGB(51, 102, 255)
Case "number 4": wRGB = RGB(255, 0, 0)
Case "number 5": wRGB = RGB(204, 153, 255)
Case "number 6": wRGB = RGB(255, 255, 255)
End Select
sh1.Shapes.Range(Array("Area_A" & j)).Select
Selection.ShapeRange.Fill.ForeColor.RGB = wRGB
End If
Next
Next
MsgBox "Done"
End Sub

many thanks in advance
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
How can you have multiple true cases if there can only be 6 cases: "number1" ,,,, "number6"

Please explain "however sometimes there is a overlap of the times, for each shape. "

If you want different colors based on the possibility of multiple true cases you will have to modify the code to be a series of if-then statements and somehow combine the individual RGB values to ghet the colors you want based on the possible combinations.

'6 taken 0 at a time = 1
'6 taken 1 at a time = 6
'6 taken 2 at a time = 15
'6 taken 3 at a time = 20
'6 taken 4 at a time = 15
'6 taken 5 at a time = 6
'6 taken 6 at a time = 1
' ----
'Possible Combinations 64

I am not sure if you can select enough colors to be readily distinguishable for 64 possibilities.
 
Upvote 0

Forum statistics

Threads
1,223,230
Messages
6,170,883
Members
452,364
Latest member
springate

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