Hi Team,
In Column A I have Emp ID, and next columns infront of it are Login hrs details
I am using multiple vlookup for getting result.just changing Column no.
Can we shorten this code by using resize in data, or any other method to achieve this Task.
Dim dwbk As Workbook
Set dwbk = Workbooks.Open(Mac.Range("b5").Value)
Dim lr As Long
lr = dwbk.Worksheets(1).Range("A1").CurrentRegion.Rows.Count
With ThisWorkbook.Sheets(2)
.Range("b2:b" & lr).FormulaR1C1 = "=VLOOKUP(RC1,'[" & dwbk.Name & "]Login Hrs'!R1C1:R" & lr & "C10,2,0)"
.Range("C2:C" & lr).FormulaR1C1 = "=VLOOKUP(RC1,'[" & dwbk.Name & "]Login Hrs'!R1C1:R" & lr & "C10,3,0)"
.Range("d2:d" & lr).FormulaR1C1 = "=VLOOKUP(RC1,'[" & dwbk.Name & "]Login Hrs'!R1C1:R" & lr & "C10,4,0)"
.Range("e2:e" & lr).FormulaR1C1 = "=VLOOKUP(RC1,'[" & dwbk.Name & "]Login Hrs'!R1C1:R" & lr & "C10,5,0)"
.Range("f2:f" & lr).FormulaR1C1 = "=VLOOKUP(RC1,'[" & dwbk.Name & "]Login Hrs'!R1C1:R" & lr & "C10,6,0)"
.Range("g2:g" & lr).FormulaR1C1 ...........and so on ... till .Range("m2:m" & lr)
End With
Thanks in advance
Regards
mg
In Column A I have Emp ID, and next columns infront of it are Login hrs details
I am using multiple vlookup for getting result.just changing Column no.
Can we shorten this code by using resize in data, or any other method to achieve this Task.
Dim dwbk As Workbook
Set dwbk = Workbooks.Open(Mac.Range("b5").Value)
Dim lr As Long
lr = dwbk.Worksheets(1).Range("A1").CurrentRegion.Rows.Count
With ThisWorkbook.Sheets(2)
.Range("b2:b" & lr).FormulaR1C1 = "=VLOOKUP(RC1,'[" & dwbk.Name & "]Login Hrs'!R1C1:R" & lr & "C10,2,0)"
.Range("C2:C" & lr).FormulaR1C1 = "=VLOOKUP(RC1,'[" & dwbk.Name & "]Login Hrs'!R1C1:R" & lr & "C10,3,0)"
.Range("d2:d" & lr).FormulaR1C1 = "=VLOOKUP(RC1,'[" & dwbk.Name & "]Login Hrs'!R1C1:R" & lr & "C10,4,0)"
.Range("e2:e" & lr).FormulaR1C1 = "=VLOOKUP(RC1,'[" & dwbk.Name & "]Login Hrs'!R1C1:R" & lr & "C10,5,0)"
.Range("f2:f" & lr).FormulaR1C1 = "=VLOOKUP(RC1,'[" & dwbk.Name & "]Login Hrs'!R1C1:R" & lr & "C10,6,0)"
.Range("g2:g" & lr).FormulaR1C1 ...........and so on ... till .Range("m2:m" & lr)
End With
Thanks in advance
Regards
mg