Code runs when it is not suppose to.

countryfan_nt

Well-known Member
Joined
May 19, 2004
Messages
719
Hello friends,

I have an excel sheet where I placed the below code by clikcing the right tab of the sheet and pasted it there (in the view code).

Here is the problem when I type something in cell C2 the code runs.
That should not happen, I only want the code to run if data is entered in cells B6,C6 or D6.
Can someone please help me.

Thanks
Nawaf

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Range("A9:D1900").AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:= _
Range("A5:D6"), Unique:=False
ActiveWindow.SmallScroll Down:=-81
Range("C8").Select
End Sub
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().

Oaktree

MrExcel MVP
Joined
Jun 20, 2002
Messages
8,010
Office Version
  1. 365
Insert
Code:
If Intersect(Target, Range("B6,C6,D6")) Is Nothing Then Exit Sub
under the Private Sub line.
 

Forum statistics

Threads
1,136,696
Messages
5,677,259
Members
419,682
Latest member
M3one

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