Ravi prasad
Board Regular
- Joined
- Feb 28, 2014
- Messages
- 115
Hi,
I've macro for vlookup. However, when i run below macros its taking lot of time to update.
I think because of the range A2:A4999 and R1C1:R4999C20.
I'm not aware of the last row(end row) in which data will be so, i have given the pre-defined range A2:A4999.
Because of this range i think its running very slow.
Can any one help me with end row.
Sub ADDCLM()
Dim ctr, Table1, Table2, cl
On Error Resume Next
Dim Dept_Row As Long
Dim Dept_Clm As Long
ctr = 0
Worksheets("SHEET1").Activate
Table1 = Sheet1.Range("A2:A4999") ' Employee_ID Column from Employee table
Table2 = Worksheets(Sheet2).Range("A2:T4999") ' Range of Employee Table 1
Dept_Row = Sheet1.Range("R2").Row ' Change E3 with the cell from where you need to start populating the Department
Dept_Clm = Sheet1.Range("R2").Column
For Each cl In Table1
'Sheet1.Cells(Dept_Row, Dept_Clm).FormulaR1C1 = "=VLOOKUP(RC[-18], R2C8:R13C9, 18, False)"
Sheet1.Cells(Dept_Row, Dept_Clm).FormulaR1C1 = "=VLOOKUP(RC1,'[Property Tax Opportunities (Previous).xlsx]Sheet1'!R1C1:R4999C20, 18,False)"
Dept_Row = Dept_Row + 1
ctr = ctr + 1
Next cl
'MsgBox "Done"
End Sub
Regards,
Ravi
I've macro for vlookup. However, when i run below macros its taking lot of time to update.
I think because of the range A2:A4999 and R1C1:R4999C20.
I'm not aware of the last row(end row) in which data will be so, i have given the pre-defined range A2:A4999.
Because of this range i think its running very slow.
Can any one help me with end row.
Sub ADDCLM()
Dim ctr, Table1, Table2, cl
On Error Resume Next
Dim Dept_Row As Long
Dim Dept_Clm As Long
ctr = 0
Worksheets("SHEET1").Activate
Table1 = Sheet1.Range("A2:A4999") ' Employee_ID Column from Employee table
Table2 = Worksheets(Sheet2).Range("A2:T4999") ' Range of Employee Table 1
Dept_Row = Sheet1.Range("R2").Row ' Change E3 with the cell from where you need to start populating the Department
Dept_Clm = Sheet1.Range("R2").Column
For Each cl In Table1
'Sheet1.Cells(Dept_Row, Dept_Clm).FormulaR1C1 = "=VLOOKUP(RC[-18], R2C8:R13C9, 18, False)"
Sheet1.Cells(Dept_Row, Dept_Clm).FormulaR1C1 = "=VLOOKUP(RC1,'[Property Tax Opportunities (Previous).xlsx]Sheet1'!R1C1:R4999C20, 18,False)"
Dept_Row = Dept_Row + 1
ctr = ctr + 1
Next cl
'MsgBox "Done"
End Sub
Regards,
Ravi