0
votes

I want to run my msgBox in action Namely, I would like to remove 2 things after clicking "Yes".

I found some solutions here:

MsgBox Yes/No Excel VBA

Excel VBA vbYesNo MsgBox

and tried to do something working. My code looks like this:

   Case "Remove"

        MsgBox "Do you want to remove all firestopping elements with their values?", 
        vbQuestion + vbYesNo
        If MsgBox(Question) = vbYes Then
        Sheets("hilti firestopping stores").Range("E5:E17").ClearContents
        Call ActiveShapes

        End If

...

   Sub Firestopshapes()
   Dim shp As Shape
   Dim Ws As Worksheet

   Set Ws = ActiveSheet
   For Each shp In Ws.Shapes
    If shp.Name = "Firestop" Then
        shp.Delete
    End If
  Next shp
 End Sub

The result is shown below:

enter image description here I also interchanged the If MsgBox(Question) = vbYes Then with If ans = vbYes Then but I am getting an error instead.

Is it some way to make this msgbox running?

1

1 Answers

3
votes

Perhaps this is clearer:

Dim ans as VbMsgBoxResult
ans = MsgBox("Do you want to remove all firestopping elements with their values?", _
    vbQuestion + vbYesNo)

If ans = vbYes Then
     ...
End If