It doesn't get much easier than this, my friend.
Code:
'CREATE A FORM (UserForm1)
'CREATE A TEXTBOX (TextBox1)
'CREATE A BUTTON (CommandButton1)
'Sheet1 CONTAINS LIST OF NAMES
'Sheet2 CONTAINS DATA ENTRY NAMES
Private Sub CommandButton1_Click()
'OPENS SHEET W/ LIST OF NAMES (Sheet1)
Sheets("Sheet1").Activate
'SEARCHES FOR MATCH IN COLUMN A
On Error Resume Next 'IF NO MATCH, CONTINUES TO NEXT CODE
NameMatch = Application.WorksheetFunction.Match(TextBox1.Text, Range("A1:A65536"), 0)
'OPENS SHEET W/ DATA ENTRY NAMES
Sheets("Sheet2").Activate
'DETERMINES NEXT BLANK ROW
NextRow = Application.WorksheetFunction.CountA(Range("A:A")) + 1
'CELLS(ROWINDEX, COLUMNINDEX)
'COUNT OF ROWS IS USED FOR THE ROW INDEX
'COLUMNINDEX 1 IS COLUMN A
Cells(NextRow, 1).Value = TextBox1.Text
'NameMatch WILL = 0 IF THERE IS NO MATCH
'COLUMNINDEX 2 IS COLUMN B
'... COLUMN B IS NEXT TO WHERE YOU JUST DROPPED THE NAME
If NameMatch = 0 Then
Cells(NextRow, 2).Value = "New"
Else
Cells(NextRow, 2).Value = "preexist"
End If
End Sub
One thing to be cautious of is that this code searches for
exact matches. And as I'm sure you already know, exact matches are a fundamental weakness of manual data entry. So be careful w/ that keyboard.
Here is the code without my comments:
Code:
Private Sub CommandButton1_Click()
Sheets("Sheet1").Activate
On Error Resume Next 'IF NO MATCH, CONTINUES TO NEXT CODE
NameMatch = Application.WorksheetFunction.Match(TextBox1.Text, Range("A1:A65536"), 0)
Sheets("Sheet2").Activate
NextRow = Application.WorksheetFunction.CountA(Range("A:A")) + 1
Cells(NextRow, 1).Value = TextBox1.Text
If NameMatch = 0 Then
Cells(NextRow, 2).Value = "New"
Else
Cells(NextRow, 2).Value = "preexist"
End If
End Sub
Is beautiful, no?
