before variable contains a value

  • Thread starter Thread starter Peter
  • Start date Start date
P

Peter

Hi all,

This is (part of) what I have:

Private Sub Worksheet_Change(ByVal Target As Range)

Dim Kpl as long

If Target.Value <> "" Then Kpl = Target.Value

....

I hope this is enough to answer the following question.

If I press delete, therefore starting the event, the variable does not yet
have a value and according to the line of code in the if-construct, it won't
get a value either.

How can you use this state of "emptyness" the variable has at that time if
you want to do something like a test and you do not want this "emptyness" to
be confused with 0?

Thanks,
Peter
 
Dim Kpl as Long

Kpl is initialized as zero, so it doesn't have a state of emptyness.

You could continue to test Target.
 

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

Back
Top