Need help with empty cell in Macro

  • Thread starter Thread starter Don
  • Start date Start date
D

Don

set var2 in macro that returns " " when cell is empty.
Need statement that says If var1 = x or var1 = y and
var2 not " " Then

Can anyone help?
 
Not quite.

1) IsEmpty is a function. So the correct use of a
function would be something more like:

If Not IsEmpty(var2)

2) IsEmpty returns True if the variable has not been
initialized, not if the variable is blank. And there is
a difference between the two. The following example
illustrates this:

Dim var1 As String
Dim var2

If IsEmpty(var1) Then
MsgBox "Var1 is Empty"
End If

If IsEmpty(var2) Then
MsgBox "Var2 is Empty"
End If


Sincerely,

Kris
 
Typo: (should be)

if (Var1 = x or var1 = y ) and not (var2 = " ") then
 

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