Run macro based on an event and cell value

Mtotheic

New Member
Joined
Dec 31, 2013
Messages
5
I am trying to run a macro when a cell within a range of cell is selected, and a cell on the same row as what is selected is not blank.

This is what i have to run the macro when a cell within the given range is selected. It works without problem.
Now I would like to throw a condition in that if the cell in column J is not blank, then a different macro would run.

Private Sub Worksheet_SelectionChange(ByVal target As Excel.Range)
If Not Intersect(target, Range("k2:n120")) Is Nothing Then
VerbiageSelection.Show

End If

End Sub
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.

Rick Rothstein

MrExcel MVP
Joined
Apr 18, 2011
Messages
38,154
Office Version
  1. 2019
  2. 2010
Platform
  1. Windows
I am trying to run a macro when a cell within a range of cell is selected, and a cell on the same row as what is selected is not blank.

This is what i have to run the macro when a cell within the given range is selected. It works without problem.
Now I would like to throw a condition in that if the cell in column J is not blank, then a different macro would run.

Private Sub Worksheet_SelectionChange(ByVal target As Excel.Range)
If Not Intersect(target, Range("k2:n120")) Is Nothing Then
VerbiageSelection.Show

End If

End Sub
Maybe this is what you are looking for...

Rich (BB code):
Private Sub Worksheet_SelectionChange(ByVal target As Excel.Range)
  If Not Intersect(target, Range("k2:n120")) Is Nothing Then
    If Not Intersect(Target.EntireRow, Columns("J")) Is Nothing Then
      VerbiageSelection.Show
    End If
  End If
End Sub

[/code]
 
Last edited:
Upvote 0

Forum statistics

Threads
1,195,835
Messages
6,011,872
Members
441,651
Latest member
drewe2000

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
Top