Results 1 to 6 of 6

How to speed up this index match function

Threaded View

  1. #1
    Registered User
    Join Date
    07-01-2015
    Location
    Singapore
    MS-Off Ver
    2013
    Posts
    66

    How to speed up this index match function

    I have these lines of codes and this macro runs really slow until it stop responding at some point of time
    Any suggestion to speed up this macro ?
    Both files are dynamic.


    Any idea?[/COLOR]
    Private Sub Unsuccessful()
    'Update Column S and T
    'S = Active Ext ID , T = Inactive Ext ID
    
    Dim MaxRowNum As Long
    
    Sheets("SimPat").Select
    
    'Set up an Error handler
    On Error GoTo errorFound
    Err.Clear
    On Error GoTo 0
    
        
    'Vlookup/IndexMatch Active Ext ID
    Range("S2").FormulaR1C1 = _
          "=INDEX('[PatientMerge.xls]2015'!C10,MATCH(C[-16],'[PatientMerge.xls]2015'!C10,0))"
    
    'Vlookup/IndexMatch Inactive Ext ID
    Range("T2").FormulaR1C1 = _
          "=INDEX('[PatientMerge.xls]2015'!C11,MATCH(C[-17],'[PatientMerge.xls]2015'!C11,0))"
        
        
        'Locate last filled row in column S (this instead of the loop)
        MaxRowNum = Range("S" & Rows.Count).End(xlUp).Row
     
        
        'Autofill the rest of the rows
        Range("S2:T2").Select
        Selection.AutoFill Destination:=Range("S2:T2" & MaxRowNum), Type:=xlFillDefault
        'Column S and T Autofit
        Columns("S:T").Select
        Columns("S:T").EntireColumn.AutoFit
                
        'Copy and Paste data as value
        Sheets("SimPat").Select 'Activate/Open Simpat again
        Range("S2:T2" & MaxRowNum).Select
        Selection.Copy
        Worksheets("Simpat").Range("U2:V2" & MaxRowNum).Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
           :=False, Transpose:=False
           
        Columns("S:S").Select
        Selection.Delete Shift:=xlToLeft
        Columns("T:T").Select
        Selection.Delete Shift:=xlToLeft
           
        Application.CutCopyMode = False
        
    With Application
            .ScreenUpdating = True
            .Calculation = xlCalculationAutomatic
    End With
    
    
    'Close the error Handler
    Exit Sub
    errorFound:
    If Err.Number > 0 Then MsgBox Err.Description, vbCritical, "Error#: & Err.Number"
    Err.Clear
    
    End Sub
    Really need it urgently

    Cross Ref: http://www.mrexcel.com/forum/excel-q...ml#post4226694



    Just updated my code cos the copy/paste and autofill wasnt working properly.
    However it is still running slow


    Private Sub Unsuccessful3()
    
    'Update Column S and T
    'S = Active Ext ID , T = Inactive Ext ID
    Dim MaxRowNum As Long
    With Application
            .ScreenUpdating = False
            .Calculation = xlCalculationManual
    End With
    Sheets("SimPat").Select
    'Set up an Error handler
    On Error GoTo errorFound
    Err.Clear
    On Error GoTo 0
        'Locate last filled row in column S (this instead of the loop)
        MaxRowNum = Range("C" & Rows.Count).End(xlUp).Row
        
    'Vlookup/IndexMatch Active Ext ID
    Range("S2:S" & MaxRowNum).Formula = "=INDEX('[PatientMerge.xls]2015'!$J:$J,MATCH(C:C,'[PatientMerge.xls]2015'!$J:$J,0))"
    'Vlookup/IndexMatch Inactive Ext ID
    Range("T2:T" & MaxRowNum).Formula = "=INDEX('[PatientMerge.xls]2015'!$K:$K,MATCH(C:C,'[PatientMerge.xls]2015'!$K:$K,0))"
        Columns("S:T").EntireColumn.AutoFit
                
        'Copy and Paste data as value
        Sheets("SimPat").Range("S2:T" & MaxRowNum).Copy
        Sheets("SimPat").Range("S2:T" & MaxRowNum).PasteSpecial Paste:=xlPasteValues
        Application.CutCopyMode = False
    With Application
            .ScreenUpdating = True
            .Calculation = xlCalculationAutomatic
    End With
    'Close the error Handler
    Exit Sub
    errorFound:
    If Err.Number > 0 Then MsgBox Err.Description, vbCritical, "Error#: & Err.Number"
    Err.Clear
    
    End Sub
    Last edited by fluffyvampirekitten; 07-27-2015 at 03:05 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Problems applying INDEX-MATCH-MATCH function on other data
    By LennartB in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 05-13-2015, 05:33 AM
  2. INDEX(MATCH)) / LOOKUPS Processing Calculator Speed
    By AstToTheRegionalMGR in forum Excel General
    Replies: 1
    Last Post: 02-17-2015, 10:57 AM
  3. [SOLVED] Stuck on Match function with #N/A; attempting to reverse Index/Match
    By Cappytano in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 12-10-2014, 06:39 PM
  4. Replies: 3
    Last Post: 06-17-2013, 12:37 PM
  5. [SOLVED] Help speed up slow INDEX (SMALL function
    By submariner18 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 12-12-2012, 01:14 PM
  6. Improving Speed of Index and Match Functions
    By hazza147 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 11-30-2010, 01:05 PM
  7. Match/Index Calcuation Speed
    By Rochy81 in forum Excel General
    Replies: 1
    Last Post: 10-01-2008, 04:19 PM

Tags for this Thread

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