[VBA Excel] si variable = vide alors...
Solved
Fritz
-
fiddy Posted messages 441 Registration date Status Contributeur Last intervention -
fiddy Posted messages 441 Registration date Status Contributeur Last intervention -
Hello,
I am working on a VBA program with a table containing references and I would like to search for a reference in this table.
However, the reference given is not necessarily in the table.
So, I created a text box to input the reference from the keyboard, and a search box with a variable.range function to find the reference in the table.
So far, so good.
After that, I want to have a variable if the reference is in the table then this happens...
and
else if the reference is not in the table then something else happens...
But I get error 91 when I don't have the same reference in the table, error = variable.range is empty.
I would like to know if we can write if variable = empty, because I don’t know how to do it. (I tried ="" and <>"")
Or if another solution exists other than searching.
Thank you.
I am working on a VBA program with a table containing references and I would like to search for a reference in this table.
However, the reference given is not necessarily in the table.
So, I created a text box to input the reference from the keyboard, and a search box with a variable.range function to find the reference in the table.
So far, so good.
After that, I want to have a variable if the reference is in the table then this happens...
and
else if the reference is not in the table then something else happens...
But I get error 91 when I don't have the same reference in the table, error = variable.range is empty.
I would like to know if we can write if variable = empty, because I don’t know how to do it. (I tried ="" and <>"")
Or if another solution exists other than searching.
Thank you.
3 réponses
Hello,
Typical example:
Lupin
Typical example:
Option Explicit Sub Test() Dim Value As Variant Value = ActiveCell.Value If (IsEmpty(Value)) Then MsgBox "Empty" Else MsgBox "Not Empty" End If End Sub
Lupin