I have some inserted rectangles on my worksheet,can I make a macro to fill the selected rectangle with a black fill color? I got the rectangle from shapes.
I have some inserted rectangles on my worksheet,can I make a macro to fill the selected rectangle with a black fill color? I got the rectangle from shapes.
Last edited by zplugger; 12-17-2018 at 03:51 PM.
Please Login or Register to view this content.
Thank you, I have 50 rectangle shapes on the sheet and only want to fill the selected one?
You could just use:
Please Login or Register to view this content.
Rory
Getting error run time 438.
What does:
show if you add it to the start of the code.Please Login or Register to view this content.
Box with Range
Then you didn't select a rectangle before running the code.
I did select the rectangle,not sure its in a certain range. Seems like its just a object.
If Typename(selection) returns Range, then you have one or more cells selected, not a rectangle, which would explain the 438 error.
If I record a macro on one of the rectangles it works,I would like it to do it to any selected rectangle on the sheet if possible.
Please Login or Register to view this content.
The code I posted will work as long as you select a rectangle first. If you mean something else by "any selected rectangle", can you please clarify what?
Trying to attach a sample workbook, can't get it to download. I can not get the code you posted to work.
Here is a example
Try assigning this code to all your shapesPlease Login or Register to view this content.
still geeting run time error
Try this file, all you need to do is click the rectangle.
Sorry, I get it now. I think I can make this work OK. Was hoping to use a commandbutton to change selected shape.
when I hoover over shape I get 4 arrows,on your example I get a hand?
The problem with using a button, is that as soon as you click the button, the button is then selected not the shape.
You will get the hand symbol because there is a macro assigned to the shape.
O I see now, Thank You for all your help,good to learn different stuff.
You're welcome & thanks for the feedback
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks