Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 12-24-2017, 08:15 AM
NoSparks NoSparks is offline How to trigger a macro on cell *selection* Windows 7 64bit How to trigger a macro on cell *selection* Office 2010 64bit
Excel Hobbyist
 
Join Date: Nov 2013
Location: British Columbia, Canada
Posts: 842
NoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of light
Default

What you're looking for is the Worksheet_SelectionChange event.

Right click the sheet tab then View Code.
Select Worksheet from the drop down where it probably says (General).
All the different worksheet events will now appear in the other drop down.

This assumes that what you are referring to as a table is in fact an Excel table, not a standard range.
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

'limit to single cell selection
If Target.Count > 1 Then Exit Sub

'limit to the first column of data in the first table on the sheet
If Intersect(Target, Me.ListObjects(1).ListColumns(1).DataBodyRange) Is Nothing Then
    Exit Sub
Else
    ' do what's required
    ' for example
    MsgBox "The sheet address of the cell you just entered is " & Target.Address
    '
    '
End If
    
End Sub
Hope this helps.
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Limit min and max number to a cell based on country selection hussainshaikh1 Excel 1 02-02-2017 07:06 AM
How do I trigger a macro from a document? brucemc777 Word VBA 4 01-25-2016 01:42 AM
How to trigger a macro on cell *selection* Selection from cell with list contents autopopulates contents of another cell markharper80 Excel 3 02-16-2015 04:18 PM
Hyperlink in cell to trigger pop up text box Carpie Excel Programming 0 08-13-2013 10:33 AM
How to trigger a macro on cell *selection* ms office excel 2007 cell selection issues pavamaklava Excel 1 05-12-2010 10:47 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:35 AM.


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