Data entry form - Duplicate searching

Macroni and cheese

New Member
Joined
Nov 23, 2017
Messages
4
Hi all!

I'm creating a data entry user form in VBA which allow the company to input/modify/remove staff members.

Each staff member has a unique ID number.

Can someone help me with a code that searches through the existing data (once they have left that textbox in the user form)to identify if the unique ID is due to be duplicated?

I'm then hoping for a pop up box to prompt to ask the user if they want to continue (Y/N) and an option to take the user to the existing Unique ID number.

Userform = AddPerson
Worksheet = Sheet1
Textbox = Staffno

Thanks in advance!!
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
You would just use the Exit event for the Staffno textbox. After that, it's just a loop through the table to look for a matching ID number.

For input of a staff member, an if statement inside the loop will check for a match; warn user of the duplicate ID and Exit Sub

For checking duplicates during modify, the loop should go all the way to the end of the data and count the number of matches found; loading the row number or address of the most recent found. If the count is more than 1, warn user of the issue.

For removal, it can be the same as the modify to make sure the correct staff member is being removed.
 
Upvote 0
I think your best option would be to use a the VBA find function to check for the ID exist. You can apply this to the Change event of the text box
 
Upvote 0

Forum statistics

Threads
1,223,908
Messages
6,175,306
Members
452,633
Latest member
DougMo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top