I can't delete a Shape in VBA

Fabrizio Leoncini 1 Reputation point
2022-12-02T16:29:52.853+00:00

Good morning
in an Excel sheet I create a Shape, an arrow, which serves to signal a row,
266660-immagine-2022-12-02-143324.png

As you can see from the image I click a button (Mark Article etc ..) and create an arrow, where it is drawn, which signals the clicked button, and so far so good. When I click on the button in the bottom row, I want to delete the existing arrow to recreate it in the row next to the button. I can't delete it because I can't find it, it's like it doesn't exist. I also attach the sub that creates the arrow shape:

Sub insertArrow(ByVal rng As Range)   
  
 Dim sh As Worksheet, s As Shape   
  
 Dim leftP As Double, topP As Double, W As Double, H As Double   
  
 'Cancella la freccia su riga di sopra   
  
  DeleteShape2 'Qui la sub dove dovrebbe cancellare la Shape  
  
 'Nome Sheet   
  
 Set sh = rng.Parent   
  
 'set la freccia larghezza and altezza (si puo cambiare)   
  
 W = 20: H = 15   
  
 leftP = rng.Left '+ rng.Width - W - 1  'calculate the horiz position   
  
 topP = rng.Top + (rng.Height - H) / 2 'calculate the vert position   
  
 Set s = sh.Shapes.AddShape(34, leftP, topP, W, H)   
  
 s.Name = s.Name   
  
 s.LockAspectRatio = msoTrue: s.Placement = xlMoveAndSize   
  
End Sub  

If someone can please give me a tip.

Thank you very much

Fabrizio

Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
4,358 questions
0 comments No comments
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.