Results 1 to 10 of 10

Speed up a VLookUp loop

Threaded View

  1. #1
    Registered User
    Join Date
    01-10-2013
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    15

    Speed up a VLookUp loop

    Hello.

    I've just finished writing a formula that looks up some information for me across multiple worksheets instead of me having to manually do it. The code works perfectly, but runs super slow . It actually seems a lot faster for me just to manually write the vlookup formula and just paste it down the worksheet . I'm wondering if anyone has any tips for speeding it up? The worksheet can have something like upwards of 30k entries I need to look up.

    The relevant code
                ActiveWorkbook.Sheets(Worksheet).Activate  'going to the worksheet that has the data I need
                localcol = FindLastCol(1) 'finding the last column in the worksheet
                col = FindCol(finding, localcol) 'finding the col that holds the data I need
    
                locallastrow = FindLastRow(Mid(Cells(1, col).Address, InStr(Cells(1, 1).Address, "$") + 1, InStr(2, Cells(1, col).Address, "$") - 2)) 'find last row of the worksheet
                myrange = Worksheet & "!" & Cells(1, 1).Address & ":" & Cells(locallastrow, col).Address  'range of the sheet to use in the vlookup
    
                ActiveWorkbook.Sheets("data").Activate 'worksheet that I want to show the data in
    
                For innercounter = 2 To max 'going through all cells in data worksheet
                    Vtest = Application.VLookup(Int(test), Range(myrange), col, False) 'test is the value I'm looking up
                    If (IsError(Vtest)) Then
                        Cells(innercounter, counter) = " "  
                    Else
                        Cells(innercounter, counter) = Vtest
                    End If
                Next innercounter
    Attached Files Attached Files
    Last edited by wizuriel; 05-10-2013 at 11:39 AM.

Thread Information

Users Browsing this Thread

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

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