Hi,

I have some code in a form that finds the matching row based on a text box and copies the data to that particular row.

Here's the code:

Private Sub cmdAddSample_Click()
Dim iRow As Long, Found As Range
Dim ws As Worksheet
Set ws = Worksheets("Data")

If txtSample.Text = "" Then
    MsgBox "Textbox is empty.", , "Invalid Entry"
    Exit Sub
Else
    'find match to textbox value
    Set Found = ws.Range("A:A").Find(What:=txtSample, SearchOrder:=xlRows, _
        SearchDirection:=xlNext, LookIn:=xlValues, LookAt:=xlWhole, MatchCase:=False)
    
    If Found Is Nothing Then
        MsgBox txtSample.Text, , "No Match Found"
        Exit Sub
    End If
End If

iRow = Found.Row

'copy the data to the database

With ws

  Application.DisplayAlerts = False
  Worksheets("SpeciesList").Range("B1:B145").Copy
  Worksheets("Data").Cells(iRow, 5).PasteSpecial Transpose:=True

End With
This works great, but if there is already data in the particular row that it finds, it gets overwritten. Is there a way to have a warning pop up if any data is in the found row, so the user doesn't accidentally overwrite a row's data?

Thanks!!
Marc