Home |
Search |
Today's Posts |
|
#1
![]() |
|||
|
|||
![]()
I am still having issues with this problem, if there is an alternative method of checking the range for a duplicate value I would be happy to use that.
Thank you for your time, Tristan |
#2
![]() |
|||
|
|||
![]()
I have now solved the issue.
For those interested the new code was: Code:
Dim dup As Object Set dupRange = Range("B5:B" & r - 1) dupSearch = Cells(r, 2) dupRange.Select Set dup = Selection.Find(What:=dupSearch, After:=ActiveCell, LookIn:=xlValues, _ LookAt:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, _ MatchCase:=False, SearchFormat:=False) If dup Is Nothing Then Resume Next End If |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello,
Ozgrid.com has a great find function (http://www.ozgrid.com/forum/showthread.php?t=27240) to return a range of cells using the Find function. You could also adapt that function to instead return a boolean if you only care about whether a duplicate exists (and don't care where the duplicate resides on the sheet). Take a look at the thread above for the Range version. I have adapted the function to return a boolean below. For example, entering: Find_Dup(Cells(r, 2), Range("B5:B33000")) would return TRUE if a duplicate value exists and FALSE otherwise. Here is that code: Function Find_Dup(Find_Item As Variant, _ Search_Range As Range, _ Optional LookIn As Variant, _ Optional LookAt As Variant, _ Optional MatchCase As Boolean) As Boolean 'Adapted from: 'http://www.ozgrid.com/forum/showthread.php?t=27240 Find_Dup = False Dim c As Range If IsMissing(LookIn) Then LookIn = xlValues 'xlFormulas If IsMissing(LookAt) Then LookAt = xlPart 'xlWhole If IsMissing(MatchCase) Then MatchCase = False With Search_Range Set c = .Find( _ What:=Find_Item, _ LookIn:=LookIn, _ LookAt:=LookAt, _ SearchOrder:=xlByRows, _ SearchDirection:=xlNext, _ MatchCase:=MatchCase, _ SearchFormat:=False) If Not c Is Nothing Then Find_Dup = True End If End With End Function |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Find function for a Range failing in excel 2003 and giving subscriptout of range error 9 problem but works fine in excel 2000 | Excel Programming | |||
Find in Named Range problem (2nd Try) | New Users to Excel | |||
INTRICATE PROBLEM- How to find multiple text,excluding "H", in a multiple range of cells, then replacing 0 with another number in another cell | Excel Worksheet Functions | |||
range.find method called into a VBA function (problem) | Excel Programming |