title: Excel VBA - How to find a value in a column and return the row it is on
body: <p>I currently use a for loop to look through column A in the HDD database sheet and when it finds the matching search criteria it copies all the information in that row into a designated area. </p>
  
  <p>I am trying to use the same for loop to tell me which row the search criteria is found on so i can delete that row from the HDD database sheet.</p>
  
  <p>Tried a few things but nothing seems to work.</p>
  
  <p>Any help is very welcome on this.</p>
  
  <pre><code>Private Sub EditButton_Click()
  
      Dim Userentry As String
      Dim i As Long
      Dim ws, ws1, ws2 As Worksheet
      'Dim found As Range
      Dim RowNumber As String
      Set ws = Sheets("HDD database")
      Set ws1 = Sheets("HDD log")
      Set ws2 = Sheets("Sheet3")
  
  
      Userentry = editTxtbox.Value
      'ws1.Range("A36").Value = Userentry
  
      For i = 1 To ws.Range("A" &amp; Rows.Count).End(xlUp).Row
          If (ws.Cells(i, 1).Value) = Userentry Then
              ws2.Range("A1").Offset(1, 0).Resize(1, 8).Value = _
                        ws.Cells(i, 1).Resize(1, 8).Value
          End If
  
      Next i
  
      addnewHDDtxtbox.Value = ws2.Range("A2")
      MakeModeltxtbox.Value = ws2.Range("B2")
      SerialNumbertxtbox.Value = ws2.Range("C2")
      Sizetxtbox.Value = ws2.Range("D2")
      Locationtxtbox.Value = ws2.Range("E2")
      Statetxtbox.Value = ws2.Range("F2")
  
  
      For i = 1 To ws.Range("A" &amp; Rows.Count).End(xlUp).Row
          If (ws.Cells(i, 1).Value) = Userentry Then
              RowNumber = ws.Cells.Row
          End If
      Next i
  
      ws1.Range("I3").Value = RowNumber
  
  End Sub
  </code></pre>