Stop Code Running after Delete

Eric Penfold

Active Member
Joined
Nov 19, 2021
Messages
424
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
Trying to stop code running after delete rows.
Using boolean to stop code running. The code below I don`t want to run after delete

VBA Code:
Public Sub Workbook_SheetBeforeDoubleClick(ByVal Sh As Object, ByVal Target As Range, Cancel As Boolean)

Dim Rng As Range
Dim NoData As Boolean
Dim Cell As Range

            If Target.Column = 1 Then
            On Error Resume Next
             Set Rng = Application.InputBox( _
                Prompt:="Select the range to Delete", _
                  Title:="Select Range", _
                      Type:=8)
                 Rng.EntireRow.Delete
                 For Each Cell In Rng
                     NoData = True And IsEmpty(Cell)
                   Next Cell
              Exit Sub
        End If

 End Sub

The code below I don`t want to run after the delete


VBA Code:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)


        If Sh.Name <> "Summary" And Sh.Name <> "Trend" And Sh.Name <> "Supplier BO" And Sh.Name <> "Dif Depot" _
        And Sh.Name <> "BO Trend WO" And Sh.Name <> "BO Trend WO 2" And Sh.Name <> "Different Depot" Then

If Target.Column = 10 Then
If Sh.Range("AA1") = "" Then
                ActiveSheet.Range("AA1") = 1
               Call BO_Drop_DownList
               Call BO_Reason
                 End If
            End If
        End If


   
    If Target.Column = 1 Then
     Call Group_OrderNos
     End If


End Sub
 
Last edited by a moderator:

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Hi Try
VBA Code:
Public Sub Workbook_SheetBeforeDoubleClick(ByVal Sh As Object, ByVal Target As Range, Cancel As Boolean)

Dim Rng As Range
Dim NoData As Boolean
Dim Cell As Range

            If Target.Column = 1 Then
            On Error Resume Next
             Set Rng = Application.InputBox( _
                Prompt:="Select the range to Delete", _
                  Title:="Select Range", _
                      Type:=8)
                Application.EnableEvents = False
                 Rng.EntireRow.Delete
                 Application.EnableEvents = True
                 For Each Cell In Rng
                     NoData = True And IsEmpty(Cell)
                   Next Cell
              Exit Sub
        End If

 End Sub
 
Upvote 0
Solution
I think your on the right road but the Rng says "Object required" not sure why?
 
Upvote 0
ok, great, thanks for marking solution
 
Upvote 0

Forum statistics

Threads
1,214,982
Messages
6,122,580
Members
449,089
Latest member
Motoracer88

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