LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Deleting several cells at once causes a VBA error

Hello group,

here is the code. This is how it works,

when a cell in the range G12:G511 is manually modified, some valors
(the result from a substraction and the current date and time) are
written in contiguous cells, when a valor is deleted from any cell in
that range, the other two valors are deleted automatically. The code
works fine until you try to delete 2 or more cells in the range, at
once. If you try, an error window will pop asking for the finishing of
the macro or to debug it.

Hopping someone can help me with this.
Thank you!


Private Sub Worksheet_Change(ByVal Target As Range)
With Application
If .Intersect(Target, Me.Range("G12:G511")) Is Nothing Then
Exit Sub

If Target.Offset(, -4) = 0 Then
.EnableEvents = False
Target.Offset(, -4) = Now
.EnableEvents = True
End If

If Len(Target.Offset(0, 0)) = 0 Then
.EnableEvents = False
Target.Offset(, -4) = ""
.EnableEvents = True
End If

If Target.Offset(0, 0) < 0 Then
Me.Cells(4, 7).Value = (Me.Cells(4, 4).Value -
Target.Offset(1, -5).Value)
End If

If Target.Offset(0, 0) = 0 Then
Me.Cells(4, 7).Value = (Me.Cells(4, 4).Value -
Target.Offset(, -5).Value)
End If

End With
End Sub

 
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
Error Deleting Columns Gk Excel Discussion (Misc queries) 4 August 20th 09 09:44 PM
Deleting Worksheet Error James McDowell[_2_] Excel Programming 3 July 20th 05 10:53 PM
Error when deleting sheets John Excel Programming 5 July 7th 05 07:27 PM
error runtime 9: deleting a worksheet [email protected] Excel Programming 4 April 7th 05 04:42 PM
Deleting Hyphens or Dashes from multiple cells without deleting the remaining content rmaloy Excel Programming 5 February 9th 04 01:59 AM


All times are GMT +1. The time now is 08:27 AM.

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

About Us

"It's about Microsoft Excel"