ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro to take cell ref of the object (https://www.excelbanter.com/excel-programming/424794-macro-take-cell-ref-object.html)

Kashyap

Macro to take cell ref of the object
 
Hi,

Say I have objects placed in Col c, d, e, f, g, h, i, j in row 8 and I need
to assign macro for each object such that

when I click on object which is in d8, then it should copy the value of d7
and paste in may be a1

when I click on object which is in e8, then it should copy the value of e7
and paste in may be a1 again.. and so on..

can anyone help me with this pls..

Thanks..

joel

Macro to take cell ref of the object
 
What type of object do you have?

You need to go into design mode to assign a macro to an object

from worksheet menu

View - Tool Bars - Control toolbox, then click on triangle ICON enter design
mode.

Then either (depends on object)
1) Right click object and select Assign Macro. Then press New
2) Double click on Object which will automatically create the macro.

Next, enter the copy line (2nd line) from code below into the macro that was
created by excel.


Sub Picture2_Click()
Range("A1").Value = Range("D7").Value
End Sub


Finally, exit design mode by clicking on Triangular Icon in the toolbar.

"Kashyap" wrote:

Hi,

Say I have objects placed in Col c, d, e, f, g, h, i, j in row 8 and I need
to assign macro for each object such that

when I click on object which is in d8, then it should copy the value of d7
and paste in may be a1

when I click on object which is in e8, then it should copy the value of e7
and paste in may be a1 again.. and so on..

can anyone help me with this pls..

Thanks..


Kashyap

Macro to take cell ref of the object
 
Hi Joel,

Actually I'm using transparent object (used for hyperlinking) its not
working..

I even tried the way you said, still its not working..

If thismobject is placed in E8, when clicked on that it should copy yje
value of E7 and paste in A1



"Joel" wrote:

What type of object do you have?

You need to go into design mode to assign a macro to an object

from worksheet menu

View - Tool Bars - Control toolbox, then click on triangle ICON enter design
mode.

Then either (depends on object)
1) Right click object and select Assign Macro. Then press New
2) Double click on Object which will automatically create the macro.

Next, enter the copy line (2nd line) from code below into the macro that was
created by excel.


Sub Picture2_Click()
Range("A1").Value = Range("D7").Value
End Sub


Finally, exit design mode by clicking on Triangular Icon in the toolbar.

"Kashyap" wrote:

Hi,

Say I have objects placed in Col c, d, e, f, g, h, i, j in row 8 and I need
to assign macro for each object such that

when I click on object which is in d8, then it should copy the value of d7
and paste in may be a1

when I click on object which is in e8, then it should copy the value of e7
and paste in may be a1 again.. and so on..

can anyone help me with this pls..

Thanks..



All times are GMT +1. The time now is 09:41 PM.

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