PDA

View Full Version : Solved: How to test formulas results?

ValerieT
03-26-2013, 01:51 AM
Hello. My question is probably very basic: I am learning bymyself VBA and I am having trouble to work with the results of a formula.

If WorksheetFunction.IsNA(Cells(Go, 20)) Then...

How to test the same way if a cell is blank or for example =6?

In this examples,
cells(Go,20) is either blank or contains a formula returning a text.
cells(Go,21) is either blank or contains a formula returning a value

To make it work, I had to first copy/paste as value the result of the formula calculation, but I am sure I could skip this step.

Thanks!

While Go < Lignes
Go = Go + 1
If Cells(Go, 20) <> "" Then :dunno
If Cells(Go, 21) > 0 Then :banghead:
....
Else
....
End If
ElseIf Cells(Go, 21) = Cells(Go,3) Then :motz2:
....
Else
End If
Wend

snb
03-26-2013, 02:36 AM
To test whether a cell is empty or not

if cells(1,1)="" Then.....
If Cells(1,1).Value="" Then ...
if Isempty(cells(1,1)) Then ...
If cells(1,1) <>"" Then ...
If Cells(1,1).Value <>"" Then ...
If not Isempty(cells(1,1)) Then ...

To test the value of a cell:

If Cells(1,1)=5 Then ...
if Cells(1,1).Value= 5 Then ....
If Cells(1,1)="text" Then ...