Pepperdine21
New Member
- Joined
- Jul 9, 2021
- Messages
- 2
- Office Version
- 365
- Platform
- Windows
I am having some trouble with some VBA code that involves copying a shape and copying a range. I am using the .Copy method for both of them and I think this is where the error is arising from.
My code looks similar to this:
When I attempt to run this code I get a runtime error. "Method 'Copy' of object 'Shape' failed. However, when I separate the code into 2 different subs the code works correctly. I think it's giving me the error for the shape object because it is the 2nd item I used the .Copy method. Is there a way to use the .Copy method (or achieve the same functionality) on 2 different items within the same sub without getting a runtime error?
My code looks similar to this:
VBA Code:
Sheets("Sheet1").Range("A2:D65").Copy
'additional code in between
Sheets("Sheet3").Range("B1").PasteSpecial xlPasteAll
'additional code in between
Dim GrpShp As Shape
Set GrpShp = Worksheets("Hidden").Shapes.Range(Array("Picture 8", "Picture 7", "Picture 9")).Group
GrpShp.Copy
'additional code after
When I attempt to run this code I get a runtime error. "Method 'Copy' of object 'Shape' failed. However, when I separate the code into 2 different subs the code works correctly. I think it's giving me the error for the shape object because it is the 2nd item I used the .Copy method. Is there a way to use the .Copy method (or achieve the same functionality) on 2 different items within the same sub without getting a runtime error?