+ Reply to Thread
Results 1 to 2 of 2

Updating Macro to use .Find & .FindNext

  1. #1
    Registered User
    Join Date
    02-24-2014
    Location
    Bishops Stortford, England
    MS-Off Ver
    Excel 2007
    Posts
    10

    Post Updating Macro to use .Find & .FindNext

    the macro below has been fine for the sreadsheets i have been working circa 20K -30k rows. however now having to work on spreadsheets that are sometimes in excess of 100k. the time in takes to traverse the spreadsheet is in hours rather than minutes. Is there a way of speeding it up?

    The macro checks, if the category is right in this case 100, then sees if there is a match between column 11 and column1 and then highlights both.

    Private Sub CommandButton2_Click()

    Dim xcnt, iUse, iRes As Long
    Dim bEnd As Boolean
    Worksheets("assetchains").Cells(3, 4).Value = "Working"
    bEnd = True
    xcnt = 4
    'find first clear row
    While (bEnd)
    If Worksheets("assetchains").Cells(xcnt, 1).Value <> "" Then xcnt = xcnt + 1 Else bEnd = False
    iRes = 0
    If Worksheets("assetchains").Cells(xcnt, 4).Value = "100" Then iRes = findchild(Worksheets("assetchains").Cells(xcnt, 1).Value)
    If iRes = 1 Then Worksheets("assetchains").Cells(xcnt, 1).Interior.ColorIndex = 6
    Worksheets("assetchains").Cells(1, 11).Value = xcnt
    Wend
    Worksheets("assetchains").Cells(3, 4).Value = "Finished"

    End Sub
    Function findchild(srchtxt)
    Dim iRes, iRes2 As Long
    Dim counter6 As Long
    Dim bchk As Boolean
    bchk = True
    iRes = 0
    iRes2 = 0
    counter6 = 4
    While (bchk)
    iRes = 0
    If Worksheets("assetchains").Cells(counter6, 10).Value = srchtxt Then iRes = 1
    If iRes = 1 Then iRes2 = iRes2 + 1
    If iRes = 1 Then Worksheets("assetchains").Cells(counter6, 10).Interior.ColorIndex = 6
    counter6 = counter6 + 1
    If Worksheets("assetchains").Cells(counter6, 1).Value = "" Then bchk = False
    Wend
    If (iRes2) Then findchild = 1 Else findchild = 0
    End Function

  2. #2
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: Updating Macro to use .Find & .FindNext

    you could do a countif before hand to see if there are any 100's there?

    Please Login or Register  to view this content.
    Hope this helps

    Sometimes its best to start at the beginning and learn VBA & Excel.

    Please dont ask me to do your work for you, I learnt from Reading books, Recording, F1 and Google and like having all of this knowledge in my head for the next time i wish to do it, or wish to tweak it.
    Available for remote consultancy work PM me

+ 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. find value in column with FindNext
    By nono in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-10-2010, 04:35 PM
  2. Cells.find and .findnext
    By Buzzaro in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-20-2007, 08:29 AM
  3. Question on FindNext vs Find
    By excelnut1954 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-18-2006, 10:00 PM
  4. Using Find & FindNext in a form
    By BernzG in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-18-2005, 07:28 PM
  5. Using 'Find' and 'FindNext' in vba
    By SA3214 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-25-2005, 09:06 AM

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