#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 108
Default duplicates

I have a userform that allows a person to type info into some textboxes and
then they can press a button and enter the data onto a worksheet. I want to
be able to check a column for one of the numbers entered to make sure there
are no duplicates. If they try to enter the same number twice i want a
message box to come up explaining what the problem is.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 290
Default duplicates

enyaw,

There is a message box asking you if you wish to stop there or keep
searching, change that to whatever action you wish to take when a
duplicate is found.

Dim oCell As Range
Dim wks As Worksheet
Dim strAddress As String
Dim FindWhat As String
Dim hawb As String
Sheets("sheet1").Select
hawb = Textbox1.Value
FindWhat = hawb
If FindWhat <= "" Then
Exit Sub
Else
For Each wks In Worksheets
'Find first occurrence in sheet
With wks.Cells
Set oCell = .Find(What:=FindWhat, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If oCell Is Nothing Then
MsgBox "Not Found on: " & .Parent.Name
Sheets("sheet1").Select
Else
strAddress = oCell.Address(External:=True)
Do
Application.GoTo oCell, Scroll:=True
If MsgBox("Stop Here?", vbYesNo, "Found at cell
" _
& oCell.Address(External:=True)) = vbYes
Then
Application.GoTo oCell
Sheets("sheet1").Select
Exit Sub
Else
Set oCell = .FindNext(oCell)
Sheets("sheet1").Select
End If
Loop Until oCell.Address(External:=True) = strAddress
End If
End With
Next wks


Hope this helps

Duncan


enyaw wrote:

I have a userform that allows a person to type info into some textboxes and
then they can press a button and enter the data onto a worksheet. I want to
be able to check a column for one of the numbers entered to make sure there
are no duplicates. If they try to enter the same number twice i want a
message box to come up explaining what the problem is.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
duplicates Pammy Excel Discussion (Misc queries) 1 December 11th 08 01:52 PM
Condensing a list with duplicates to a list with non-duplicates Nuclear Excel Worksheet Functions 2 July 29th 08 08:03 PM
Duplicates in excel that aren't 100% DUPLICATES ... [email protected] Excel Discussion (Misc queries) 4 May 2nd 08 06:43 PM
Don't allow duplicates Mark Excel Discussion (Misc queries) 2 September 12th 07 06:40 AM
Duplicates Krissie C Excel Discussion (Misc queries) 3 November 16th 05 01:17 PM


All times are GMT +1. The time now is 08:02 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"