Worksheet Selection Change

D

DEFJ

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
 
C

Chip Pearson

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
 
T

Tom Ogilvy

if isempty(Target) then exit sub

at the top is a possibility.

or

if not isempty(target) then
' other checks

End if
 
D

Dave Peterson

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top