VBA code to fill shape transparent with any RGB colour cases

harjotawang

New Member
Joined
Nov 22, 2021
Messages
16
Office Version
  1. 2021
Platform
  1. Windows
this my code, i dont know how to make "case 0" become transparency

Sub Fillcolor()
For i = 1 To 10
API = Sheet1.Cells(i + 1, 7)
Select Case API

Case 0
a = 255
b = 255
b = 255
Case 1
a = 150
b = 100
Case 2
a = 255
b = 0
Case Else
a = 255
b = 0
End Select
Sheet1.Shapes.Range(Array("Freeform: Shape " & i)).Fill.ForeColor.RGB = RGB(a, b, 0)
Next i
End Sub
 
Cross-posting (posting the same question in more than one forum) is not against our rules, but the method of doing so is covered by #13 of the Forum Rules.

Be sure to follow & read the link at the end of the rule too!

Cross posted at: please help me, yhe shape wouldnt change if i change value
If you have posted the question at more places, please provide links to those as well.

If you do cross-post in the future and also provide links, then there shouldn’t be a problem.
 
Upvote 0

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
That code works for me. Do you get any error messages?
that code works for me too, but if i change case value from tranparency value into colour value, the shape doesnt change.

this code work from my problem

Sub fillcolour()
For i = 1 To 3
API = Sheet1.Cells(i + 1, 3)
With Sheet1.Shapes("gambar " & i).Fill
Select Case API
Case 0
.Visible = msoTrue
.Solid
.ForeColor.SchemeColor = 8
.Transparency = 0#
Case 1
.Visible = msoTrue
.Solid
.ForeColor.SchemeColor = 12
.Transparency = 0#
Case 2
.Visible = msoFalse
.Solid
.Transparency = 0#
End Select

End With
Next i
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,219
Messages
6,123,678
Members
449,116
Latest member
HypnoFant

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