title: VBA Sub to locate a cell based on Top row and First Column
body: <p>My top row is state's Name such as VA CA, first column contains industry code. Need a VBA sub that after I click this Button named Locate, a msgbox asks user to put the State name, a second msgbox asks user to put the industry code, vba finds which column and row that state and industry is at, locate the value based on these 2 coordinates input.  </p>
  
  <pre><code>Sub Locate()
  Dim siccode As Integer
  Dim rngSearch As Range, rngFound, rngFound2 As Range
  Dim r As Double
  Dim c As Double
  Dim states, cellvalue As String
  
  siccode = InputBox(Prompt:="Please enter 2 digit SIC code: ", Title:="SIC   Code", Default:="SIC here")
  states = InputBox(Prompt:="Please enter State name: ", Title:="State Name", Default:="State Name here")
  
  Set rngSearch = Range("A:BB")
  Set rngFound = rngSearch.Find(What:="siccode", LookIn:=xlValues, LookAt:=xlPart)
   If rngFound Is Nothing Then
   MsgBox "No claims at all"
   Else
   MsgBox rngFound.Row
   End If
  
  Set rngSearch = Range("A:BB")
  Set rngFound2 = rngSearch.Find(What:="states", LookIn:=xlValues, LookAt:=xlPart)
  If rngFound2 Is Nothing Then
   MsgBox "No Claims at all"
   Else
   MsgBox rngFound2.Column
   End If
  
  cellvalue = ActiveSheet.Cells(rngFound.Row, rngFound2.Column).value
  MsgBox (cellvalue)
  End Sub
  </code></pre>
  
  <p>it works fine till the if part, no matter what input it is, it always shows no claims at all. </p>