UserForm not finding multiple entries

Status
Not open for further replies.

manny88

New Member
Joined
Oct 28, 2016
Messages
33
I was looking for a code that will help me look for multiple/dupes in a worksheet when entering information from a userform.

I struggled with this and searched google high and low and used the code:

VBA Code:
If IsError (Application.Match (Me.NameTextBox, Worksheets("Admin").Columns(3),0)) Then
MsgBox "Entry already exists.", vbCritical
Exit Sub
End If

A bad copy and paste job, perhaps. Instead of telling me only that entry already exists in the sheet, it is telling anything and everything I enter already exists in the sheet, which is wrong.

I fear the issue is either the IsError or the Match telling it to showing everything as a duplicate. Please help in amended/improving this code!
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
try including the Not operator & see if your code will now do what you want

Rich (BB code):
If Not IsError(Application.Match(Me.NameTextBox, Worksheets("Admin").Columns(3), 0)) Then
MsgBox "Entry already exists.", vbCritical
Exit Sub
End If

Dave
 
Upvote 0
Cross posted Duplicate VBA code not working!

While we do allow Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule 13 here along with the explanation: Forum Rules). This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered.
 
Upvote 0
that will teach me not to check first! Thanks @Fluff
Hi Fluff, Dave,

I have never double posted like that before. I'm up against it with this one, so my sincerest apologies have noted! I will make a note of it on the other post too

Dave - thanks for the reply. I did try adding NOT, and tried it again just, but that doesn't find the duplicate entry and instead adds it to the sheet as if it were a unique reference
 
Upvote 0
What sort of values do you have in column C of Admin?
 
Upvote 0
If Column C has a mix of text & numbers, then you will have problems. A textbox contains text, so if you enter 123 it will not find the number 123 in that column.
The easiest way would be to convert col C to text.
 
Upvote 0
If Column C has a mix of text & numbers, then you will have problems. A textbox contains text, so if you enter 123 it will not find the number 123 in that column.
The easiest way would be to convert col C to text.
I can't do that as the reference entered are always prefixed with letters followed by numbers and on some occasions include a "/" within the reference. I wanted to code to find the exact match if and tell the user it is a duplicate.
 
Upvote 0
Please supply links to ALL other sites where you have asked this question.
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,215,352
Messages
6,124,449
Members
449,160
Latest member
nikijon

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