Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
don don is offline
external usenet poster
 
Posts: 21
Default Delete key causes error in Worksheet_Change in 2003

I have a piece of code which is not working correctly in 2003

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Target.Column = 4 Then
Set TargetCell = Target
Call Procedure1
ElseIf Target.Column = 8 Then
Set TargetCell = Target
Call Procedure2
END Sub


Public TargetCell As Excel.Range

Sub Procedure1

If TargetCell.Value = "" Then
TargetCell.Offset(0, 2).Formula = "=0"
TargetCell.Offset(0, 5).Formula = "=0"
TargetCell.Offset(0, 7).Formula = "=I" & TargetCell.Row
TargetCell.Offset(-94, 2).Formula = "=0"
End Sub
Sub Procedure2

If TargetCell.Value = "" Then
TargetCell.Formula = "=0"
TargetCell.Offset(0, 1).Formula = "=0"
TargetCell.Offset(0, 2).Formula = "=0"
End Sub

In column 8, if I select a blank item from my validation list, or edit the cell and backspace to delete all the characters, this works, but if I press the Delete key, I get a Type Mismatch Error on the line, 'If TargetCell.Value = "" Then'


In column 4, using the Delete Key works fine, but the Offsets do not all work correctly. (0,2) and (0,7) work fine. (0,5) does nothing to remove the previous cell contents, and (-94,2) actually edits the cell at (-94,4) ????

Any ideas gratefully received.


Mahalo

Don


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default Delete key causes error in Worksheet_Change in 2003

Unless I am missing something, this should do the same thing.

if target < "" and target < " " then
if target.column=4 then _
target.Offset(0, 7).Formula = "=I" & Target.Row
end if
end sub
--
Don Guillett
SalesAid Software

"Don" wrote in message
...
I have a piece of code which is not working correctly in 2003

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Target.Column = 4 Then
Set TargetCell = Target
Call Procedure1
ElseIf Target.Column = 8 Then
Set TargetCell = Target
Call Procedure2
END Sub


Public TargetCell As Excel.Range

Sub Procedure1

If TargetCell.Value = "" Then
TargetCell.Offset(0, 2).Formula = "=0"
TargetCell.Offset(0, 5).Formula = "=0"
TargetCell.Offset(0, 7).Formula = "=I" & TargetCell.Row
TargetCell.Offset(-94, 2).Formula = "=0"
End Sub
Sub Procedure2

If TargetCell.Value = "" Then
End Sub


In column 8, if I select a blank item from my validation list, or edit the

cell and backspace to delete all the characters, this works, but if I press
the Delete key, I get a Type Mismatch Error on the line, 'If
TargetCell.Value = "" Then'


In column 4, using the Delete Key works fine, but the Offsets do not all

work correctly. (0,2) and (0,7) work fine. (0,5) does nothing to remove the
previous cell contents, and (-94,2) actually edits the cell at (-94,4) ????

Any ideas gratefully received.


Mahalo

Don




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 event handler error gen Excel Discussion (Misc queries) 0 January 18th 08 04:55 AM
Compile error: Ambigious name detected: Worksheet_Change **NEWBIE** dan Excel Discussion (Misc queries) 1 May 26th 06 10:13 AM
Excel 2003 has wrong timing using the worksheet_change macro Jan Excel Worksheet Functions 0 January 14th 06 06:30 AM
worksheet_change vs. calculate, and worksheet_change not running Tom Ogilvy Excel Programming 1 July 14th 03 02:51 AM
worksheet_change vs. calculate, and worksheet_change not running Ross[_5_] Excel Programming 0 July 13th 03 04:27 PM


All times are GMT +1. The time now is 12:42 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"