Need macro to fill color

djl0525

Well-known Member
Joined
Dec 11, 2004
Messages
1,240
I'm trying to create a macro to change the fill color of the selected object to black. I recorded a macro and got the code below. It works unless I select an object with a group which is what I need it for.

Can this code be modified to change the fill color the selected object in a group?
Sub Fill_Black()
'
' Fill_Blank Macro

Selection.ShapeRange.Fill.ForeColor.SchemeColor = 8

End Sub

-- DJ
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
HI
Your problem is not clear. if you want to change to different color, change no 8 to the color of your choice
Code:
 For a = 1 To 50
    Selection.ShapeRange.Fill.ForeColor.SchemeColor = a
    MsgBox a
    Next a
select the object and Run the code to choose the color index
Ravi
 
Upvote 0
Thank you for your reply. I will try to clarify my problem...

I have grouped several AutoShapes. I frequently need to change the color of individual AutoShapes in the group.

Here's what I do manually:
I select a group of AutoShapes. I click again to select an object in the group. Then I click a fill color and the selected shape is filled with the selected color. I can record a macro to fill the group of AutoShapes, but I don't want it to fill everything in the group. I need it to fill the selected AutoShape in the group.

Is my explanation of the problem clearer?

-- DJ

By the way, I tried your code. It gets me 50 message boxes that display 1-50, not an input box where I can put in a number.
 
Upvote 0
Hi
Code:
a= inputbox("enter the color code for the selected shape")
    Selection.ShapeRange.Fill.ForeColor.SchemeColor = a
Select one or more of shapes and run the macro. My earlier macro was to find the color code of the color of your choice.
Ravi
 
Upvote 0
Thanks, but the challenge is not selecting a color. The challenge is getting the selected color to be applied to an object within the group.

-- DJ
 
Upvote 0
Hi
the macro changes the color of selected shapes. if you want to programmatically change it, you should list the names of the objects to be selected. each shape has a name and number ex: "Rectangle 2", "Text Box 5", "Oval 3", "Line 4", triangle 7 etc. use
ActiveSheet.Shapes("Rectangle 2").Select and color it.
Ravi
 
Upvote 0
It's too bad VB does not recognize that I have already selected the object I want to color within the group. But I'll try to work with this.

Thanks a bunch! -- DJ
 
Upvote 0

Forum statistics

Threads
1,214,824
Messages
6,121,783
Members
449,049
Latest member
greyangel23

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