+ Reply to Thread
Results 1 to 2 of 2

Search and Find Macro runs too slow

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    05-31-2013
    Location
    Philadelphia, Pa
    MS-Off Ver
    Excel 2010
    Posts
    170

    Search and Find Macro runs too slow

    Hello All!

    So I wrote the following code to run on a button click. Essentially, I want to to loop through a column of data until the end. For each cell that has data it will search for a match in another column on another worksheet. If a match is found various cells adjacent to it are copied and brought back to the first worksheet and pasted alongside the original cell.

    I got all of this working fine, however, it takes too long to run. I have a list of over 2000 items, and after running for 2 minutes the code only got through 200 lines. Can you help me speed it up at all?

    Sub Loop_All()
    Dim x
    Dim y As Worksheet
    Dim founddata As Range
    Do Until IsEmpty(ActiveCell.Value)
    
    x = ActiveCell.Value
    Set y = ActiveSheet
    Set founddata = Worksheets("Data Archive").Cells.Find(what:=x, LookIn:=xlValues)
    Application.ScreenUpdating = False
    Worksheets("Data Archive").Select
    Range([A1], [A:A].Find("*", [A1], , , xlByRows, xlPrevious)).Select
    If founddata Is Nothing Then
        ActiveCell.Offset(1, 0).Select
    Else: founddata.Activate
        ActiveCell.Offset(0, 1).Resize(1, 4).Copy
        y.Select
        ActiveCell.Offset(0, -4).PasteSpecial
    ActiveCell.Offset(0, 13).Select
        ActiveCell.Value = Date
    ActiveCell.Offset(1, -9).Select
    End If
        
    Loop
    Application.ScreenUpdating = True
    Exit Sub
    
    
    End Sub

  2. #2
    Forum Contributor HerryMarkowitz's Avatar
    Join Date
    09-10-2012
    Location
    Europe
    MS-Off Ver
    Office 2021 - Win10
    Posts
    1,014

    Re: Search and Find Macro runs too slow

    Your code can not to be faster...
    But, we can supply another way if you can attach your file...
    Sub DontForgetThese()
         If Your thread includes any code Then Please use code tags...
         If Your thread has been solved Then Please mark as solved...
         If Anybody has helped to you Then Please add reputation...
    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. [SOLVED] macro runs slow on save
    By Fred33 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-18-2015, 04:25 PM
  2. [SOLVED] Macro runs really slow when going to one sheet
    By cory0789 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-23-2014, 11:38 PM
  3. Excel2003 Macro runs slow???
    By Infinity in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-07-2006, 01:55 AM
  4. Macro runs slow
    By Sandy in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 09-20-2005, 12:05 PM
  5. macro runs slow
    By nanomiter in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-11-2005, 01:06 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