• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Delete Rectangle shapes in a particular range [VBA]

vijay.vizzu

Member
Hi all,


Below code is working fine for me, but i want to delete shapes in a particular range in the newly created sheet. please help me to get rid of this. I don't want to delete all shapes in my sheet

[pre]
Code:
Sub saveCreate()
Dim countWs As Integer  'To count total sheets in workbook
Dim numLtrs As Integer  'To count number of characters in vendor name
Dim vName As String     'To save vendor name

Application.ScreenUpdating = False

countWs = Worksheets.Count 'counts total sheets in workbook

Sheets("temp").Copy after:=Sheets(countWs) 'Copy & paste temp in end of the sheets
numLtrs = WorksheetFunction.Find(" ", [venName]) - 1 'counts number of intial characters before space
vName = Left([venName], numLtrs) 'gets vendor name
ActiveSheet.Name = vName 'rename the sheet with vendor name
Sheets("temp").Activate 'returns to main template
Range("rngAdd").ClearContents 'clear the contents
Range("vendcd").ClearContents 'clear the contents
Range("rngData").ClearContents 'clear the contents

Application.ScreenUpdating = True
End Sub
[/pre]

Regards

Vijay
 
Vijay


You can refer to shapes by name


eg:

ActiveSheet.Shapes.Range(Array("Rectangle 1")).Delete


ActiveSheet.Shapes.Range(Array("Huis Shape")).Delete


ActiveSheet.Shapes.Range(Array("Huis Shape1","Huis Shape 2","Huis Shape 03")).Delete
 
Thank you hui, it works like a charm. i am new to VBA, so can you please explain why you have used array with range object. I learned that we can use array to copy entire worksheet to new location. I just want to know this trick also.


It will be pleasure if you explain


Vijay
 
Back
Top