Hi there,
Using the following VBA code (to delete the shapes in the selected cells) doesn't always work. Sometimes it does sometimes it doesn't, crazy right? The same sheet, the same cell layout and no error messages, yet something prevents the deletion. What is it that I'm missing?
Here is the code I'm using to insert the shapes followed by the code that is supposed to delete them based on cell selection:
The code I'm using to delete the shapes:
Thanks for any help.
Using the following VBA code (to delete the shapes in the selected cells) doesn't always work. Sometimes it does sometimes it doesn't, crazy right? The same sheet, the same cell layout and no error messages, yet something prevents the deletion. What is it that I'm missing?
Here is the code I'm using to insert the shapes followed by the code that is supposed to delete them based on cell selection:
VBA Code:
Private Sub cmdKantoorwerkHalf_Click()
ActiveSheet.Unprotect
Dim cell As Range
Dim shp As Shape
For Each cell In Selection
If IsDate(cell.Value) And cell.Interior.Color <> RGB(255, 217, 102) Then
Set shp = ActiveSheet.Shapes.AddShape(msoShapeRightTriangle, cell.Left, cell.Top, cell.Width, cell.Height)
shp.Fill.Visible = msoTrue
shp.Fill.ForeColor.RGB = RGB(0, 255, 0)
shp.Fill.Transparency = 0.5
shp.Line.Visible = msoFalse
cell.Offset(1, 0).Value = "#KH"
End If
Next cell
ActiveSheet.Protect
End Sub
The code I'm using to delete the shapes:
VBA Code:
Private Sub cmdWissen_Click()
ActiveSheet.Unprotect
Dim cell As Range
Dim shp As Shape
For Each shp In ActiveSheet.Shapes
If Not Intersect(Selection, shp.TopLeftCell) Is Nothing Then
shp.Delete
End If
Next shp
ActiveSheet.Protect
End Sub
Thanks for any help.