Get name of shape and copy to another sheet

haseft

Active Member
Joined
Jun 10, 2014
Messages
321
Hi!

In activecell there is a shape.
I want to get its name and copy it to another sheet.
Please help.

Sub CopyShape()
Dim shp as string

shp=Activecell .Shape.name
shp=copy
Application.Goto Sheets("Blad7").Range("B2")
ActiveSheet.Paste

End Sub
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
[I forgot to mention that the following codes do not work.]

Hi!

In activecell there is a shape.
I want to get its name and copy it to another sheet.

Please help.

Sub CopyShape()
Dim shp as string

shp=Activecell .Shape.name
shp=copy
Application.Goto Sheets("Blad7").Range("B2")
ActiveSheet.Paste

End Sub[/QUOTE]
 
Upvote 0
Code:
Public Sub CopyAndPasteShape()


    With "Your Sheet1 Object"
    
        .Shapes("Shape Name").Copy
        
    End With
    
    With "Your Sheet2 Object"
    
        .Paste Destination:=.Range("Cell Reference")
        
    End With


End Sub
 
Upvote 0
Hi

The problem is that I do not know the name of the shape in active cell.
I know in cell D28 is a shape, but don't know the name.

Code:
Public Sub CopyAndPasteShape()
Worksheets("Blad1").Activate
 Range ("D28").Select
 With Worksheets("Blad1")
       .Shapes("Shape Name").Copy
    End With
    
    With Worksheets("Process")
        .Paste Destination:=.Range("D1")
    End With
End Sub
 
Last edited:
Upvote 0
Ok, you don't need to activate or select an object before you use it and I would try to avoid doing so unless you have a good reason.

Why don't you know the name of the shape?

Thanks.
 
Upvote 0
I pasted a word document and organizing it to a sheet.
There are many shapes in it.
For ex. I look up for a text "mytext" and then select Activecell.Offset.(1,0), there is a shape in this cell, witch I want to copy it to an other sheet.
 
Last edited:
Upvote 0
Place this function in the same General Module as your macro and then, when you need the name of the shape located above (shapes are above, not in, cells) the active cell, simply call it...

ShapeName = ShapeAtActiveCell

or you can use it directly in your Shapes object call...

.Shapes(ShapeAtActiveCell).Copy

Here is the code for the function...
Code:
Function ShapeAtActiveCell() As String
  Dim Sh As Shape
  For Each Sh In ActiveSheet.Shapes
    If Sh.TopLeftCell.Address = ActiveCell.Address Then
      ShapeAtActiveCell = Sh.Name
      Exit Function
    End If
  Next
End Function
 
Last edited:
Upvote 0
Hi Rick!
Still not working.
Code:
Public Sub CopyAndPasteShape()

Worksheets("Blad1").Activate
    With Worksheets("Blad1")
       .Shapes(ShapeAtActiveCell).Copy
    End With
    
    With Worksheets("Process")
        .Paste Destination:=.Range("D1")
    End With

End Sub
 
Last edited:
Upvote 0
Thanks Rick and RobMG.
Nu its working perfect.
I forgot to paste the function ShapeAtActiveCell.
Thanks a lot.
 
Upvote 0
Hi Rick!
Still not working.
Code:
Public Sub CopyAndPasteShape()

Worksheets("Blad1").Activate
    With Worksheets("Blad1")
       .Shapes(ShapeAtActiveCell).Copy
    End With
    
    With Worksheets("Process")
        .Paste Destination:=.Range("D1")
    End With

End Sub
Actually, I just read what you said you wanted in Message #1 and realized your code is structured incorrectly. To get the name of the shape over the active cell on the Brad1 sheet placed in cell D1 on the Process worksheet, try using this code (with my function from Message #7 installed)...
Code:
Public Sub CopyAndPasteShape()
 
  Worksheets("Blad1").Activate
  Worksheets("Process").Range("D1").Value = ShapeAtActiveCell

End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,214,979
Messages
6,122,559
Members
449,089
Latest member
Motoracer88

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