ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Macros (https://www.excelbanter.com/excel-discussion-misc-queries/27498-macros.html)

Pese

Macros
 
I have multiple objects (ovals) in one column of a spreadsheet. I am able to
create macros with corresponding buttons that once clicked, will change the
color of the first oval to either red, yellow, or green. I want these macros
to apply to any of the objects in the column. Thus, I want to be able to
click on any object in the column and then click the corresponding macro
button that will change the color of the object to that which is desired.
How do I set the macros so that they do not just apply to the first oval
object, but that I can run them on any of the objects?

greg

Pese,
if I read this correctly, create you macro as you have, but do not choose a
cell during the recording.
Click on a cell before you run a macro, then record your macro.
The macro should change/add info. to the cell which is currently seleceted.
Choose a cell before running the macro, then run the macro.
Hope it helps.

"Pese" wrote:

I have multiple objects (ovals) in one column of a spreadsheet. I am able to
create macros with corresponding buttons that once clicked, will change the
color of the first oval to either red, yellow, or green. I want these macros
to apply to any of the objects in the column. Thus, I want to be able to
click on any object in the column and then click the corresponding macro
button that will change the color of the object to that which is desired.
How do I set the macros so that they do not just apply to the first oval
object, but that I can run them on any of the objects?


Pese

Greg,
I'm still having problems because when I record the macro, I have to select
the object that I want to change color (the object is simply an oval created
from the drawing toolbar). It's not a cell, but an object in the cell.
Thus, once the macro is recorded, it is "tagged" to that specific oval/object
that I selected to change the color to. I want to be able to run that macro
on multiple ovals, resulting in the ability to change the color of any of
them, not just the one that I selected in the macro recording. Any further
suggestions?

"greg" wrote:

Pese,
if I read this correctly, create you macro as you have, but do not choose a
cell during the recording.
Click on a cell before you run a macro, then record your macro.
The macro should change/add info. to the cell which is currently seleceted.
Choose a cell before running the macro, then run the macro.
Hope it helps.

"Pese" wrote:

I have multiple objects (ovals) in one column of a spreadsheet. I am able to
create macros with corresponding buttons that once clicked, will change the
color of the first oval to either red, yellow, or green. I want these macros
to apply to any of the objects in the column. Thus, I want to be able to
click on any object in the column and then click the corresponding macro
button that will change the color of the object to that which is desired.
How do I set the macros so that they do not just apply to the first oval
object, but that I can run them on any of the objects?


Dave Peterson

You can assign the same macro to each of the ovals. In fact, you can change the
color in that same macro. This might give you some ideas to play with:

Option Explicit
Sub testme()
Dim myShape As Shape
Set myShape = ActiveSheet.Shapes(Application.Caller)
myShape.Fill.ForeColor.SchemeColor = 14
End Sub

Pese wrote:

I have multiple objects (ovals) in one column of a spreadsheet. I am able to
create macros with corresponding buttons that once clicked, will change the
color of the first oval to either red, yellow, or green. I want these macros
to apply to any of the objects in the column. Thus, I want to be able to
click on any object in the column and then click the corresponding macro
button that will change the color of the object to that which is desired.
How do I set the macros so that they do not just apply to the first oval
object, but that I can run them on any of the objects?


--

Dave Peterson


All times are GMT +1. The time now is 05:14 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com