+ Reply to Thread
Results 1 to 3 of 3

findnext cease to function

  1. #1
    Valued Forum Contributor bulina2k's Avatar
    Join Date
    11-20-2012
    Location
    Urziceni, Ialomita, Romania
    MS-Off Ver
    2019 and 365
    Posts
    867

    findnext cease to function

    Hello guys!
    The following code works very well:

    Please Login or Register  to view this content.
    but if I put some code into loop, FindNext doesn't work anymore:


    Please Login or Register  to view this content.

    Any ideas?

    Thanks!
    .. and don't forget to have fun!
    Bogdan.

    mark SOLVED and Add Reputation if my answer pleases you

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,015

    Re: findnext cease to function

    If you use another Find within the loop, your original FindNext won't work. You have to use Find again repeating all the parameters.
    Last edited by romperstomper; 05-08-2015 at 09:28 AM.
    Everyone who confuses correlation and causation ends up dead.

  3. #3
    Forum Contributor
    Join Date
    03-21-2012
    Location
    Ho Chi Minh city
    MS-Off Ver
    Excel 2003
    Posts
    180

    Re: findnext cease to function

    PHP Code: 
    Option Explicit
    Private Sub Worksheet_Change(ByVal Target As Range)
     Const 
    Rws0 As Long 165
     
    If Not Intersect(Target, [e5]) Is Nothing Then
        Dim Sh 
    As WorksheetRng As RangesRng As Range
        Dim MyAdd 
    As String:                            ReDim Arr(11 To 1651 To 7)
        
    Dim Tmr As DoubleRws As LongCol As LongOffs As LongHg As Long
        
        Rows
    ("11:" Rws0).Hidden False:              Tmr Timer
        Range
    ("B11:G" Rws0).ClearContents:            Randomize
        Target
    .Interior.ColorIndex 34 Rnd() \ 1
        Application
    .ScreenUpdating False
        Set Sh 
    ThisWorkbook.Worksheets("NKC"):        Hg 11
        Rws 
    Sh.[E65500].End(xlUp).Row:                Set Rng Sh.Range("F8:G" Rws)
        
    Set sRng Rng.Find(Target.Value, , xlFormulasxlWhole)
        If 
    sRng Is Nothing Then
            
    [e11].Value "Nothing":                    Rows("13:" Rws0).Hidden True
        
    Else
            
    MyAdd sRng.Address                        '<=|'
            
    Do
                
    Rws sRng.Row:                         Col sRng.Column
                
    If Col 6 Then Offs Else Offs = -1
                Arr
    (Hg1) = Sh.Cells(Rws"B").Value
                Arr
    (Hg2) = Sh.Cells(Rws"c").Value
                Arr
    (Hg3) = Sh.Cells(Rws"D").Value
                Arr
    (Hg4) = Sh.Cells(Rws"e").Value
                Arr
    (Hg5) = sRng.Offset(, Offs).Value
                Arr
    (HgCol) = Sh.Cells(Rws"H").Value
                Hg 
    Hg
                Set sRng 
    Rng.FindNext(sRng)           '<=|'
            
    Loop While Not sRng Is Nothing And sRng.Address <> MyAdd
        End 
    If
        [
    B11].Resize(Hg 17).Value Arr()
        
    Rws = [e10].End(xlDown).Row 2
        
    If Rws Rws0 Then
            
    [e11].Value "Nothing":                    Rws 13
        End 
    If
        
    Rows(Rws ":" Rws0).Hidden True
        Application
    .ScreenUpdating True
        
    [k65500].End(xlUp).Offset(1).Value Timer Tmr
     End 
    If
    End Sub 

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 7
    Last Post: 02-18-2013, 04:40 PM
  2. [SOLVED] VBA FindNext function does not work in a function
    By ArnolddG in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-23-2013, 07:24 PM
  3. findnext fails after function call
    By chergh in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-01-2008, 03:56 AM
  4. Tools cease working
    By c mateland in forum Excel General
    Replies: 1
    Last Post: 06-30-2006, 10:50 PM
  5. adapting the findnext function
    By chrisrowe_cr in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-02-2005, 01:05 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1