I have a table and I want to trigger a macro when I click on values in a specific column of that table.
I found a piece of code online to put as the worksheet code to accomplish this. The code is as follows:
The
Now, I am having a problem. The code calls that macro anywhere in the sheet is clicked. I want the desired click area to be one specific column of the table.
What can we edit in the code to accomplish my requirement?
Sheet name : Sheet1
Table name : Table1
Column number : 5 (Where I want to click to trigger macro)
Column header : EmpName
Thank you.
I found a piece of code online to put as the worksheet code to accomplish this. The code is as follows:
VBA Code:
Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim myRng
myRng = Selection.Address
If Selection.Count = 1 Then
If Not Intersect(Target, Range(myRng)) Is Nothing Then
Call SelectEmpRow
End If
End If
End Sub
The
SelectEmpRow
is the macro I want to run when a cell in the specific column of the table is clicked.Now, I am having a problem. The code calls that macro anywhere in the sheet is clicked. I want the desired click area to be one specific column of the table.
What can we edit in the code to accomplish my requirement?
Sheet name : Sheet1
Table name : Table1
Column number : 5 (Where I want to click to trigger macro)
Column header : EmpName
Thank you.