Application Intersect

paulstan

Board Regular
Joined
Mar 12, 2011
Messages
85
Hi

I have the following code (which works perfectly - almost). My Case Select is based around Coulmn AD; however, my data starts at row 8 of the Column, with the previous 7 rows being taken up with headers etc. My problem is that if someone types something into my header at Col AD, Rows 1-7, then whichever row they type into changes to white. I would like the Select Case to start from Row 8 and ignore all prior rows.

Is there a simple change that I need to do to my code?

Regards and thanks for looking.

Paul S


Code:
Private Sub Worksheet_Change(ByVal Target As Range)
     If Application.Intersect(Target, Columns("AD")) Is Nothing Then Exit Sub
Select Case Target
    Case "Cleared : no problem"
        Target.Offset(, -29).Resize(, 31).Interior.ColorIndex = 35
    Case "Cleared : unable to check"
        Target.Offset(, -29).Resize(, 31).Interior.ColorIndex = 38
    Case "Cleared : errors"
        Target.Offset(, -29).Resize(, 31).Interior.ColorIndex = 7
    Case "Not Cleared : information requested"
        Target.Offset(, -29).Resize(, 31).Interior.ColorIndex = 8
    Case "Not Cleared : claim not processed"
        Target.Offset(, -29).Resize(, 31).Interior.ColorIndex = 9
    Case "Not Cleared : not actioned"
        Target.Offset(, -29).Resize(, 31).Interior.ColorIndex = 10
    Case Else
       ' Change Col header title first, then uncheck line below
        Target.EntireRow.Interior.ColorIndex = xlColorIndexNone
End Select
End Sub
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Try

Code:
If Application.Intersect(Target, Columns("AD")) Is Nothing Or Target.Row < 8 Then Exit Sub
 
Upvote 0
Try changing this
If Application.Intersect(Target, Columns("AD")) Is Nothing Then Exit Sub
to
If Application.Intersect(Target, Range("AD8:AD" & Rows.Count)) Is Nothing Then Exit Sub

Hope that helps.
 
Upvote 0
Quick response folks!!

Both of those suggestions work.

Thanks very much for your most valuable time.

Regards

Paul S
 
Upvote 0

Forum statistics

Threads
1,224,604
Messages
6,179,857
Members
452,948
Latest member
UsmanAli786

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