Results 1 to 6 of 6

Slow Macro Execution

Threaded View

  1. #1
    Registered User
    Join Date
    09-04-2013
    Location
    richardson, tx
    MS-Off Ver
    Excel 20037
    Posts
    28

    Slow Macro Execution

    I created a macro to retrieve data from a worksheet based on the contents of a cell within the same workbook. However, the macro runs slowly at first then gets slower. The workbook has several worksheets but I am only using 2. I import customer data into Sheets(1) and have my search data formatted as text - this is a column of numbers which I do not want to treat as numbers. The search numbers in Sheets(1) are a subset of the complete number in Sheets(2). For example, in Sheets(1), I use 062825 to search Sheets(2) to find 011874000061825. Numbers in both sheets are formatted as text.

    I sort both sheets on the data value I am interested in then use a For..Next loop to grab each input value and search Sheets(2). I included a code fragment below for evaluation. All variables are initialized prior to For loop. At this time, Sheets(1) has 250 lines while Sheets(2) has approx 1357 lines.

    Any comments will be appreciated.

        For n = 1 To last_RMA - LastRMARow
            Cells(LastRMARow + n, 4).Select
            imei = ActiveCell
            Sheets(2).Activate
    
            For m = p To last_V2_row
                o = Right(Cells(m, 1), 6)                ' used to evaluate process
                If o = Right(imei, 6) Then
                    Cells(m, 1).Range("A1:M1").Cut
                    p = m                                            ' placeholder
                    Sheets(1).Activate
                    ActiveSheet.Paste
                   Exit For
                End If
            Next
            
            If m >= last_V2_row Then                        ' added in event search term does not exist in Sheets(2)
                Sheets(1).Activate
            End If
            Application.CutCopyMode = False
            
        Next
    Thank you
    Gandalf2524
    Last edited by Gandalf2524; 09-04-2013 at 04:15 PM. Reason: add code tags

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Slow VBA execution
    By GustavBA in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-03-2013, 06:40 AM
  2. Slow Macro execution
    By rickparker in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-29-2012, 11:16 AM
  3. Help - Excel 2003 Macro execution SLOW!
    By C C in forum Excel General
    Replies: 5
    Last Post: 12-02-2005, 12:35 PM
  4. Slow code execution
    By side_ in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-21-2005, 01:44 PM
  5. [SOLVED] Macro Slow In Execution Under Excel 2002
    By samson in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-02-2005, 04: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