Results 1 to 5 of 5

adding "Yes/No" message box to delete row macro

Threaded View

Dannypak adding "Yes/No" message box... 05-07-2009, 01:19 PM
Leith Ross Re: adding "Yes/No" message... 05-07-2009, 01:24 PM
Paul Re: adding "Yes/No" message... 05-07-2009, 01:25 PM
royUK Re: adding "Yes/No" message... 05-07-2009, 01:25 PM
Dannypak Re: adding "Yes/No" message... 05-07-2009, 02:02 PM
  1. #1
    Registered User
    Join Date
    03-11-2009
    Location
    Seattle, WA
    MS-Off Ver
    Office 2007
    Posts
    58

    adding "Yes/No" message box to delete row macro

    Hello,

    I'm using the following code to do conditional delete row, but would like to add a message box to confirm the "delete" with a Yes/No msgbox. I'd like to have the macro exit when the user clicks "no" but I'm missing something here.
    Thank you in advance for your help

    Sub DeleteRowsVendorUS()
        Const sTOFIND As String = "void"
         varanswer = MsgBox("Are you sure you want to delete these rows?", vbYesNo, "alert")
        Dim rngToCheck As Range, rngCell As Range, rngToDelete As Range
        
        Application.ScreenUpdating = False
        
        With Sheet7
            Set rngToCheck = .Range(.Cells(1, 1), .Cells(.Rows.Count, 1).End(xlUp))
        End With
        
        For Each rngCell In rngToCheck
            If rngCell.Value = sTOFIND Then
                If rngToDelete Is Nothing Then
                    Set rngToDelete = rngCell
                Else
                    Set rngToDelete = Union(rngToDelete, rngCell)
                End If
            End If
        Next rngCell
            
        If Not rngToDelete Is Nothing Then rngToDelete.EntireRow.Delete
        
        Application.ScreenUpdating = True
    End Sub
    Last edited by Dannypak; 05-07-2009 at 02:02 PM. Reason: solved

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1