Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 325
Default Prevent error when deleting row within Worksheet_Change target ran

Good afternoon, all,

I posted this problem earlier, but perhaps didn't explain it too well.

I have a database in columns B:D and I use the following event code to
change the interior colour of a data row, based on the value entered into
column D of that row. (named "ColorIndexCol" - D5:D59)

Private Sub Worksheet_Change(ByVal Target As Range)
Dim Intersection As Range
Set Intersection = Intersect(Target, Range("ColorIndexCol"))
If Not Intersection Is Nothing Then
If Not Target Is Nothing Then
Target.Offset(0, -2).Resize(1, 3).Interior.ColorIndex =
Target.Value
End If
End If
End Sub

Whilst this works fine, if I delete any row between 5 and 59 i.e. within the
"ColorIndexCol" range), I get the error "Aplication defined or object defined
error", highlighting the "target.offset... line.

As you can see, I've tried to trap the error by using if not target is
nothing, but it doesn't work. Does anyone know how I can resolve this, please?

Thanks in advance

Pete



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Worksheet_change Target Address is Reference Cell mpreddy[_4_] Excel Programming 0 September 29th 04 09:46 AM
Worksheet_change Target Address is Reference Cell mpreddy[_3_] Excel Programming 0 September 29th 04 08:53 AM
How find if target is object in Worksheet_Change (ByVal Target As.. ?) Gunnar Johansson Excel Programming 3 July 1st 04 09:25 PM
Error with Target.Name.Name in Worksheet_Change event SuperJas Excel Programming 2 January 8th 04 03:26 AM
Many Sub Worksheet_Change(ByVal Target As Range) In One Worksheet MathewPBennett Excel Programming 4 December 24th 03 01:01 PM


All times are GMT +1. The time now is 09:55 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"