Yes button in vbyesno not working...

ellehcer08

New Member
Joined
Jul 25, 2011
Messages
31
hi!! can someone tell me how to make this code work.. (button YES, in vbYesNo is not working)

Code:
Private Sub cmdDelete_Click()
  
Dim RecipeDel
Dim r As Range
Dim SourceDel As String
Dim CategoryDel As String
Dim faddress As String
Dim PageDel As String
    With Me
        CategoryDel = .lbxSearch.Column(1)
        RecipeDel = .lbxSearch.Column(2)
        SourceDel = .lbxSearch.Column(3)
        PageDel = .lbxSearch.Column(4)
    End With
    
    With Sheets("Recipe_Page").Range("RecipeRange")
    Set r = .Find(What:=CategoryDel, LookAt:=xlPart, LookIn:=xlValues, MatchCase:=False)
    If Not r Is Nothing Then
        faddress = r.Address
        
        answer = MsgBox("Delete this??", vbYesNo)
        
        If vbNo Then Exit Sub
        End If
        
        If vbYes Then
        Do
            If r.Offset(0, 1) = RecipeDel And r.Offset(0, 2) = SourceDel And _
                r.Offset(0, 3) = PageDel Then
                r.EntireRow.Delete
        Exit Do
        End If
                
  
        Set r = .FindNext(r)
    Loop While Not r Is Nothing And r.Address <> faddress

Else
    MsgBox "Nothing found... Try Again!!", vbInformation + vbOKOnly
    Me.txtSearch = ""
    Me.txtSearch.SetFocus
End If

 
End With
    With Me
        .txtSearch.Value = ""
        .txtRecipe.Value = ""
        .txtPageNum.Value = ""
        .cboCategory2.Value = ""
        .cboSource2.Value = ""
        .lbxSearch.Clear
        .cmdAdd.Enabled = True
        .cmdGO.Enabled = True
        .cmdDelete.Enabled = False
        .cmdReplace.Enabled = False
    End With
End Sub



Please help!!!! thanks a lot...
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.

Forum statistics

Threads
1,224,509
Messages
6,179,192
Members
452,893
Latest member
denay

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top