If target.intersect begins with a bracket "(" then exit sub..

omairhe

Well-known Member
Joined
Mar 26, 2009
Messages
2,040
Office Version
  1. 2019
Platform
  1. Windows
Hello all,

In the following code if the change in value occurs in range M5:M1000 the code will run. However, this is true with any value change. What if I would like to neglect the code operation from change code if the value in that range (M5:M1000) begin with a "(" bracket. And thus do nothing if this case is true.

VBA Code:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Dim KeyCells As Range
Set KeyCells = Range("M5:M1000")
If Not Application.Intersect(KeyCells, Range(Target.Address)) _
Is Nothing Then

Thanks and will appreciate.
 
After some playing around with your code I was able to solve this like.

VBA Code:
If Not Intersect(Target, Range("M5:M1000")) Is Nothing Then
If Left(Target.Offset(0, 1).PivotItem.Value, 1) <> "(" Then

I guess they say it right. 'Little goes a long way.' Hehe
But yh sorry to not have posted the information about the pivot table in my original post.

Ty
 
Upvote 0

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Glad I was able to help you.
Come back here to Mr. Excel next time you need additional assistance.
 
Upvote 0

Forum statistics

Threads
1,215,038
Messages
6,122,798
Members
449,095
Latest member
m_smith_solihull

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