![]() |
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. |
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. |
All times are GMT +1. The time now is 04:19 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com