Data Range too huge and VBA takes longer time to complete run formula

Ann Ooi

New Member
Joined
Jun 12, 2020
Messages
40
Office Version
  1. 365
Platform
  1. Windows
I have this code to insert vlookup formula into a range of data, due to the lines is over 50K, it takes very long time to complete the whole process. Anyway to avoid this running time and able to apply the formula successfully?

VBA Code:
Sub LookupPrime()

    Dim r As Range
    Dim s As Range
    Dim lastA As Long
                
    Application.ScreenUpdating = False
    
    ThisWorkbook.Worksheets("InvList").Select
     
    lastA = Range("A" & Rows.Count).End(xlUp).Row
         
    Range("R1").Value = "lookup"
    Range("S1").Value = "Wafer Type"
    
    Set r = Range("R2" & ":R" & lastA)
    r.Formula = "=VLOOKUP(Q2,PRef!A:B,2,0)"
    r.Value = r.Value
    
    Set s = Range("S2" & ":S" & lastA)
    s.Formula = "=IF(ISERROR(R2),P2,R2)"
    s.Value = s.Value

    Application.ScreenUpdating = True

End Sub
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.

Forum statistics

Threads
1,215,061
Messages
6,122,921
Members
449,094
Latest member
teemeren

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top