Change Event Macro on Condition

rex759

Well-known Member
Joined
Nov 8, 2004
Messages
608
Office Version
  1. 365
Platform
  1. Windows
Hello,
I wrote a change event macro based on the user entering a number higher than 1 in the range D4:D27. It’s working, currently.

I want to add a condition so the macro only runs if the corresponding cell in column B has the word “Survey” or “Review”.

I tried using an And statement on this line but could not get it to work.

Code:
If Not Intersect(Target, Range("D4:D27")) Is Nothing Then


Any help is greatly appreciated.

Below is a snippet of the code.


Code:
'if the user enters a number other than 1 in column D
If Not Intersect(Target, Range("D4:D27")) Is Nothing Then
    b = Target.Value
        If b > 1 Then

'find last range
 Dim LastR As Long
    With Worksheets("Totals")
      LastR = .Cells(.Rows.Count, "S").End(xlUp).Row
      LastR = LastR + 1
    End With
    
myname = Target.Offset(0, 2).Value
 

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.
Try:

Code:
If Not Intersect(target, Range("D4:D27")) Is Nothing And (Cells(target.Row, "B").Value = "Survey" Or Cells(target.Row, "B").Value = "Review") Then
 
Upvote 0
Try:

Code:
If Not Intersect(target, Range("D4:D27")) Is Nothing And (Cells(target.Row, "B").Value = "Survey" Or Cells(target.Row, "B").Value = "Review") Then

Ugh, I wasnt even close. Works perfectly. Thank you!
 
Upvote 0

Forum statistics

Threads
1,215,958
Messages
6,127,937
Members
449,412
Latest member
sdescharme

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