title: Msgbox not working in Excel VBA
body: <p>I would like to filter data based on inputbox in my excel table. Then copy the data to another sheet. I used the code below. The code is almost working. But when there is no data available, I would like to show a message. In my code message1 and message2 both are not working.</p>
  
  <pre><code>Sub Findrpnumber()
      Call Clearoldrp
  
      Dim str1 As Variant
      Dim Tbl As ListObject
      Dim FiltRng As Range
      Dim RngArea As Range
  
      Set Tbl = Sheet2.ListObjects("DataTable")
      str1 = Application.InputBox("Select the RP Number")
  
      If str1 = False Then
          MsgBox "Please Enter one RP number", , "Find RP Data"
          Exit Sub
      Else
          Tbl.Range.AutoFilter Field:=1, Criteria1:=str1
          For Each RngArea In Tbl.Range.SpecialCells(xlCellTypeVisible).Rows
              If RngArea.Row &gt; 1 Then
                  If Not FiltRng Is Nothing Then
                      Set FiltRng = Application.Union(FiltRng, RngArea)
                  Else
                      Set FiltRng = RngArea
                  End If
              End If
          Next RngArea
  
          If Not FiltRng Is Nothing Then 'Filter range is not empty
              FiltRng.Copy Sheets("Chart").Range("A1")
              MsgBox "Data available on Chart Sheet" 'Message1
          Else
              MsgBox "RP Number not found" 'Message2
          End If
      End If
      Sheet2.ListObjects("DataTable").Range.AutoFilter Field:=1
  End Sub
  </code></pre>