Consulting

Results 1 to 2 of 2

Thread: Solved: How to test formulas results?

  1. #1
    VBAX Regular
    Joined
    Mar 2013
    Posts
    80
    Location

    Unhappy Solved: How to test formulas results?

    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.

    example I've already used...
    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!

    [VBA]While Go < Lignes
    Go = Go + 1
    If Cells(Go, 20) <> "" Then
    If Cells(Go, 21) > 0 Then
    ....
    Else
    ....
    End If
    ElseIf Cells(Go, 21) = Cells(Go,3) Then
    ....
    Else
    End If
    Wend[/VBA]
    Last edited by Aussiebear; 03-26-2013 at 03:58 AM. Reason: added the correct tags to the supplied code

  2. #2
    Knowledge Base Approver VBAX Guru
    Joined
    Apr 2012
    Posts
    4,920
    To test whether a cell is empty or not

    [VBA]
    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 ...
    [/VBA]

    To test the value of a cell:

    [VBA]
    If Cells(1,1)=5 Then ...
    if Cells(1,1).Value= 5 Then ....
    If Cells(1,1)="text" Then ...
    [/VBA]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •