Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21922

If Else not working

$
0
0
I can't seem to get my else statement to work. Basically if the value of cellRef is Null i want a pop up message, any suggestions why this is not working? Many Thanks in advance!

Code:

Private Sub displaybtn_Click()
 
Dim ni_num As String
Dim ni_num_missing_one As String

 
ni_num = TextBox1.Value & TextBox2.Value & TextBox3.Value & TextBox4.Value & TextBox5.Value
ni_num_missing_one = TextBox1.Value & TextBox2.Value & TextBox3.Value & TextBox4.Value & " "
 
cellRef = Cells.Find(ni_num, LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False).Address

    If IsNull(cellRef) Then

        cellRef = Cells.Find(ni_num_missing_one, LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False).Address

    End If


    If Not IsNull(cellRef) Then

        Range(cellRef).Activate
        Me.Resultbox = ActiveCell.Offset(0, -1).Value

  Else

        MsgBox "Not Found"


    End If


Viewing all articles
Browse latest Browse all 21922

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>