Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
My code exits without a warning or going to completion. Any
thoughts? It seems to exit on the Loop While line. Function Find_Range(Find_Item As Variant, Search_Range As Range, _ Optional LookIn As Variant, Optional LookAt As Variant, _ Optional MatchCase As Boolean) As Range Dim firstAddress 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 Set Find_Range = c firstAddress = c.Address Do Set Find_Range = Union(Find_Range, c) Set c = .FindNext(c) Loop While Not c Is Nothing And c.Address < firstAddress End If End With End Function Thanks, Jay |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Try making the single line "Loop While Not c Is Nothing And c.Address < firstAddress" into two
lines... '--- If c is Nothing then Exit Do Loop While c.Address < firstAddress '--- Jim Cone Portland, Oregon USA . http://www.mediafire.com/PrimitiveSoftware . (XL Companion add-in: compares, matches, counts, lists, finds, deletes...) "jlclyde" wrote in message ... My code exits without a warning or going to completion. Any thoughts? It seems to exit on the Loop While line. Function Find_Range(Find_Item As Variant, Search_Range As Range, _ Optional LookIn As Variant, Optional LookAt As Variant, _ Optional MatchCase As Boolean) As Range Dim firstAddress 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 Set Find_Range = c firstAddress = c.Address Do Set Find_Range = Union(Find_Range, c) Set c = .FindNext(c) Loop While Not c Is Nothing And c.Address < firstAddress End If End With End Function Thanks, Jay |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Excel 2007 exits without asking if I want to save | Excel Discussion (Misc queries) | |||
Prompt msg if the worksheet already exits | New Users to Excel | |||
Find if value exits in array | Excel Worksheet Functions | |||
Closing a workbook, exits Excel 2007 too | Excel Discussion (Misc queries) | |||
Excel Exits on File Close with Outlook | Excel Discussion (Misc queries) |