![]() |
debug message pops up when I select a range of cells and delete
Hello,
When i select a range of cells and hit delete, a that debug message appears. The range in question is controlled by the following sytax in VB: If target.Row < 10 Or target.Row 13 Then Exit Sub Application.EnableEvents = False If target.Column = 8 Then If IsNumeric(target) = False Then If Len(target) 0 Then target.Offset(0, -2) = "" End If End If End If Application.EnableEvents = True End Sub i have to sometimes select this range of cells all at once and delete, but how can I prevent the debug message from appearing. |
debug message pops up when I select a range of cells and delete
What does the message say?
-- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Brian" wrote in message ... Hello, When i select a range of cells and hit delete, a that debug message appears. The range in question is controlled by the following sytax in VB: If target.Row < 10 Or target.Row 13 Then Exit Sub Application.EnableEvents = False If target.Column = 8 Then If IsNumeric(target) = False Then If Len(target) 0 Then target.Offset(0, -2) = "" End If End If End If Application.EnableEvents = True End Sub i have to sometimes select this range of cells all at once and delete, but how can I prevent the debug message from appearing. |
debug message pops up when I select a range of cells and delet
run time error 13
type mismatch "Chip Pearson" wrote: What does the message say? -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Brian" wrote in message ... Hello, When i select a range of cells and hit delete, a that debug message appears. The range in question is controlled by the following sytax in VB: If target.Row < 10 Or target.Row 13 Then Exit Sub Application.EnableEvents = False If target.Column = 8 Then If IsNumeric(target) = False Then If Len(target) 0 Then target.Offset(0, -2) = "" End If End If End If Application.EnableEvents = True End Sub i have to sometimes select this range of cells all at once and delete, but how can I prevent the debug message from appearing. |
debug message pops up when I select a range of cells and delet
I suspect an error in a cell.
As an experiment, I entered =1/0 into a cell to give me #DIV/0 Then tried MsgBox Len(Selection) This gave me Run-time Error 13 You can check for an error: iserror(selection) Keep in mind your Target may span many cells, not just one. -- Rob van Gelder - http://www.vangelder.co.nz/excel "Brian" wrote in message ... run time error 13 type mismatch "Chip Pearson" wrote: What does the message say? -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Brian" wrote in message ... Hello, When i select a range of cells and hit delete, a that debug message appears. The range in question is controlled by the following sytax in VB: If target.Row < 10 Or target.Row 13 Then Exit Sub Application.EnableEvents = False If target.Column = 8 Then If IsNumeric(target) = False Then If Len(target) 0 Then target.Offset(0, -2) = "" End If End If End If Application.EnableEvents = True End Sub i have to sometimes select this range of cells all at once and delete, but how can I prevent the debug message from appearing. |
debug message pops up when I select a range of cells and delet
OP doesnt check that Target.Count =1 if the target contains multiple cells: Len(target) will produce runtime error. whereas len(target.cells(1)) would not. normally i'd include if Target.Count < 1 then exit sub -- keepITcool | www.XLsupport.com | keepITcool chello nl | amsterdam Rob van Gelder wrote : I suspect an error in a cell. As an experiment, I entered =1/0 into a cell to give me #DIV/0 Then tried MsgBox Len(Selection) This gave me Run-time Error 13 You can check for an error: iserror(selection) Keep in mind your Target may span many cells, not just one. |
debug message pops up when I select a range of cells and delet
len(Range("B1:B2"))
produces type mismatch (len with a multi-cell argument). If you want to process multiple cells for each cell in Target If cell.Row < 10 Or cell.Row 13 Then Exit Sub Application.EnableEvents = False If cell.Column = 8 Then If IsNumeric(cell) = False Then If Len(cell) 0 Then cell.Offset(0, -2).ClearContents End If End If End If Application.EnableEvents = True End Sub -- Regards, Tom Ogilvy "Rob van Gelder" wrote in message ... I suspect an error in a cell. As an experiment, I entered =1/0 into a cell to give me #DIV/0 Then tried MsgBox Len(Selection) This gave me Run-time Error 13 You can check for an error: iserror(selection) Keep in mind your Target may span many cells, not just one. -- Rob van Gelder - http://www.vangelder.co.nz/excel "Brian" wrote in message ... run time error 13 type mismatch "Chip Pearson" wrote: What does the message say? -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Brian" wrote in message ... Hello, When i select a range of cells and hit delete, a that debug message appears. The range in question is controlled by the following sytax in VB: If target.Row < 10 Or target.Row 13 Then Exit Sub Application.EnableEvents = False If target.Column = 8 Then If IsNumeric(target) = False Then If Len(target) 0 Then target.Offset(0, -2) = "" End If End If End If Application.EnableEvents = True End Sub i have to sometimes select this range of cells all at once and delete, but how can I prevent the debug message from appearing. |
All times are GMT +1. The time now is 06:40 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com