Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-20-2018, 01:39 AM
trevorc trevorc is offline Worksheet_BeforeDoubleClick Windows 7 32bit Worksheet_BeforeDoubleClick Office 2013
Competent Performer
Worksheet_BeforeDoubleClick
 
Join Date: Jan 2017
Posts: 174
trevorc will become famous soon enoughtrevorc will become famous soon enough
Default Worksheet_BeforeDoubleClick

Hi all,
I'd like to know how to use the code below on several worksheets that have the same fields, I use different sheets for each of our customers and would like to be able to add a new customer without having to add the vba code to each worksheet. Can I put it in the workbook reference somehow to make it work for all sheets in the workbook, based on the activesheet reference or is this not possible?

Sample found on web...

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Not Intersect(Target, Range("A3:A25")) Is Nothing Then


'code
'code
'code
End If
End Sub

Last edited by trevorc; 02-20-2018 at 01:40 AM. Reason: Title update
Reply With Quote
  #2  
Old 02-20-2018, 05:26 AM
Debaser's Avatar
Debaser Debaser is offline Worksheet_BeforeDoubleClick Windows 7 64bit Worksheet_BeforeDoubleClick Office 2010 32bit
Competent Performer
 
Join Date: Oct 2015
Location: UK
Posts: 221
Debaser will become famous soon enough
Default

Yes, you need the Workbook level equivalent. This needs to be in the ThisWorkbook module:

Code:
Private Sub Workbook_SheetBeforeDoubleClick(ByVal Sh As Object, ByVal Target As Range, Cancel As Boolean)
    If Not Intersect(Target, Sh.Range("A3:A25")) Is Nothing Then
    'code
    'code
    'code
    End If
End Sub
Reply With Quote
  #3  
Old 02-20-2018, 12:16 PM
trevorc trevorc is offline Worksheet_BeforeDoubleClick Windows 7 32bit Worksheet_BeforeDoubleClick Office 2013
Competent Performer
Worksheet_BeforeDoubleClick
 
Join Date: Jan 2017
Posts: 174
trevorc will become famous soon enoughtrevorc will become famous soon enough
Thumbs up Solved

Thanks for that, It works great.

Last edited by trevorc; 02-20-2018 at 12:20 PM. Reason: tried to set solved but can't get to it ?
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
PIVOT TABLES adding several FILTERS that do not intersect between them Squall LH Excel 0 11-09-2017 08:46 AM
Intersect tinfanide Excel Programming 1 07-27-2014 06:14 AM
Worksheet_BeforeDoubleClick What application to use? pfergy Office 1 03-12-2011 08:46 PM
Worksheet_BeforeDoubleClick Best application to use? FrankW Office 2 06-13-2009 01:16 AM
Application.Caller pankajkankaria Excel 0 03-18-2009 11:48 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:52 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft