I can only use the code below once then it won`t fire the code again.

Eric Penfold

Active Member
Joined
Nov 19, 2021
Messages
424
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
Also I would like to end sub when user presses Cancel how is this possible when it`s a range of cells in inputbox

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
Dim Text As Variant
               
            Set Rng = Application.InputBox( _
                Prompt:="Select the range to Delete", _
                  Title:="Select Range", _
                      Type:=8)
                Application.EnableEvents = False
                 Rng.EntireRow.Delete
                 Exit Sub
                 Application.EnableEvents = True
                 
        End Sub
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Can you upload a copy of your workbook (any sensitive data disguised or removed) to one of DropBox, OneDrive, Google Drive etc and provide a public share link here so we can take a look?
Your workbook seems to be behaving differently to mine and I have been unable to determine the difference through my questions.
 
Upvote 0
Please send your email address so i could send it to you. I have never used the above sorry
 
Upvote 0
Ok thanks please take a look at the link below let me know if it worked
Yes, that worked, thanks.

That workbook has yet another different Workbook_SheetBeforeDoubleClick code.

The End just before the End Sub line does nothing, as does the If Cancel = False Then line together with its matching End If line

Other than that, the code seems to basically be working for me and there was no triggering of the Workbook_SheetChange code from anything I tried in relation to double-clicking on any worksheet and selecting or cancelling when the Input Box did appear.

Can you spell out the steps that I need to take to cause the problem that you are having?
 
Upvote 0
Yes, that worked, thanks.

That workbook has yet another different Workbook_SheetBeforeDoubleClick code.

The End just before the End Sub line does nothing, as does the If Cancel = False Then line together with its matching End If line

Other than that, the code seems to basically be working for me and there was no triggering of the Workbook_SheetChange code from anything I tried in relation to double-clicking on any worksheet and selecting or cancelling when the Input Box did appear.

Can you spell out the steps that I need to take to cause the problem that you are having?
Sorry i keep trying to find a answer at the same time i have people asking me why it not sorted yet. I think if you press cancel it will exit sub is that not right? Otherwise there is a error.

Every time I press Ok or Cancel in InputBox it runs the first code fine but still runs onto the second code. Because there is a trigger in second code which i can`t seem to stop working for this procedure.
See the trigger below

VBA Code:
     If Target.Column = 1 Then
     Call Group_OrderNos
     End If
 
Upvote 0
I'm afraid that I cannot reproduce your problem.
 
Upvote 0

Forum statistics

Threads
1,215,139
Messages
6,123,263
Members
449,093
Latest member
Vincent Khandagale

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