Hi,
i am using the below code:
What its supposed to do is to delete one grouped shapes (one rectangle, plus some charts and possibly few other elements) in the given range.
Then once it is deleted, macro should copy new grouped shape/charts form another sheet based on the predefined name in "list" variable.
Problem is that once macro loops from shapes in range and that one group of objects is deleted, it attemps to loop through it again when object was deleted and returns error as it cannot find nothing. Error is runtime error 1004. This only occurs when I change value in cell N2 as defined in "list" variable, seems like after changing values in range "n2" (it is drop down menu) macro loops again through range when its empty and returns this error.
Would you know whats the issue?
Thanks,
i am using the below code:
What its supposed to do is to delete one grouped shapes (one rectangle, plus some charts and possibly few other elements) in the given range.
Then once it is deleted, macro should copy new grouped shape/charts form another sheet based on the predefined name in "list" variable.
Problem is that once macro loops from shapes in range and that one group of objects is deleted, it attemps to loop through it again when object was deleted and returns error as it cannot find nothing. Error is runtime error 1004. This only occurs when I change value in cell N2 as defined in "list" variable, seems like after changing values in range "n2" (it is drop down menu) macro loops again through range when its empty and returns this error.
Would you know whats the issue?
Thanks,
Code:
Sub x()
Dim s As Shape
list = Workbooks("OriginalXXL.xlsm").Sheets("Sheet1").Range("N2")
Sheets("Sheet1").Select
For Each s In ActiveSheet.Shapes
If Not Intersect(Range("B2:I17"), s.TopLeftCell) Is Nothing Then
s.Delete
End If
Next s
Sheet24.Select
ActiveSheet.Shapes.Range(Array(list)).Select
Selection.Copy
Sheets("Sheet1").Select
Range("B3").Select
ActiveSheet.Paste
Range("P4").Select
End Sub