ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Worksheet Selection Change (https://www.excelbanter.com/excel-programming/282659-worksheet-selection-change.html)

DEFJ

Worksheet Selection Change
 
I have an if/then statement on the worksheet "Change"
method that checks the value of 'target' and acts
accordingly. It works except when you use 'Delete' to
empty out the cell. I get a data mismatch error. I'm
guessing it's because target can't equal 'null'. Is there
any way around this?

Thanks in advance

Chip Pearson

Worksheet Selection Change
 
It would be most helpful if you posted the code that is causing the problem.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"DEFJ" wrote in message
...
I have an if/then statement on the worksheet "Change"
method that checks the value of 'target' and acts
accordingly. It works except when you use 'Delete' to
empty out the cell. I get a data mismatch error. I'm
guessing it's because target can't equal 'null'. Is there
any way around this?

Thanks in advance




Tom Ogilvy

Worksheet Selection Change
 
if isempty(Target) then exit sub

at the top is a possibility.

or

if not isempty(target) then
' other checks

End if

--
Regards,
Tom Ogilvy

DEFJ wrote in message
...
I have an if/then statement on the worksheet "Change"
method that checks the value of 'target' and acts
accordingly. It works except when you use 'Delete' to
empty out the cell. I get a data mismatch error. I'm
guessing it's because target can't equal 'null'. Is there
any way around this?

Thanks in advance




DEFJ

Worksheet Selection Change
 
thanks again- works great (saved me from an ActiveCell
workaround)
-----Original Message-----
if isempty(Target) then exit sub

at the top is a possibility.

or

if not isempty(target) then
' other checks

End if

--
Regards,
Tom Ogilvy

DEFJ wrote in

message
...
I have an if/then statement on the worksheet "Change"
method that checks the value of 'target' and acts
accordingly. It works except when you use 'Delete' to
empty out the cell. I get a data mismatch error. I'm
guessing it's because target can't equal 'null'. Is

there
any way around this?

Thanks in advance



.


Dave Peterson[_3_]

Worksheet Selection Change
 
I read this as trying to clear the contents of a range.

if you were doing
Target.delete

try:

Application.enableevents = false
target.clearcontents
application.enableevents = true

Disabling events means that changing the sheet in code doesn't cause the change
event to fire.



DEFJ wrote:

I have an if/then statement on the worksheet "Change"
method that checks the value of 'target' and acts
accordingly. It works except when you use 'Delete' to
empty out the cell. I get a data mismatch error. I'm
guessing it's because target can't equal 'null'. Is there
any way around this?

Thanks in advance


--

Dave Peterson



All times are GMT +1. The time now is 09:23 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com