I have 5 columns B F G I J. A simplified version of what I want to do is illustrated by the following data:
B F G I J
[TABLE="width: 576"]
<colgroup><col width="64" style="width:48pt" span="9"> </colgroup><tbody>[TR]
[TD="width: 64, bgcolor: transparent, align: right"]1[/TD]
[TD="width: 64, bgcolor: transparent"][/TD]
[TD="width: 64, bgcolor: transparent"][/TD]
[TD="width: 64, bgcolor: transparent"][/TD]
[TD="width: 64, bgcolor: transparent, align: right"]674[/TD]
[TD="width: 64, bgcolor: transparent"][/TD]
[TD="width: 64, bgcolor: transparent"][/TD]
[TD="width: 64, bgcolor: transparent"]1[/TD]
[TD="width: 64, bgcolor: transparent, align: right"]106.00%[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, align: right"]2[/TD]
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent, align: right"]701.5[/TD]
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent"]2[/TD]
[TD="bgcolor: transparent, align: right"]79.50%[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, align: right"]3[/TD]
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent, align: right"]736.2[/TD]
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent"]3[/TD]
[TD="bgcolor: transparent, align: right"]102.70%[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, align: right"]4[/TD]
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent, align: right"]778.2[/TD]
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent"]4[/TD]
[TD="bgcolor: transparent, align: right"]111.00%
[/TD]
[/TR]
</tbody>[/TABLE]
I want to use VLOOKUP to enter formulae into the G column using VLOOKUP, and multiply the result by the values in column Fbut can not get it to work in VBA.
The code I have tried is:
Sub lookuptest1()
Dim i As Long
Dim lookup_range As Range
Set lookup_range = Range("I3:J6")
Range("G3").Select
For i = 0 To 3
ActiveCell.Offset(i, 0).FormulaR1C1 = "=RC[-1]*vlookup(RC[-5],lookup_range,2)"
Next
Could somebody help me please?
B F G I J
[TABLE="width: 576"]
<colgroup><col width="64" style="width:48pt" span="9"> </colgroup><tbody>[TR]
[TD="width: 64, bgcolor: transparent, align: right"]1[/TD]
[TD="width: 64, bgcolor: transparent"][/TD]
[TD="width: 64, bgcolor: transparent"][/TD]
[TD="width: 64, bgcolor: transparent"][/TD]
[TD="width: 64, bgcolor: transparent, align: right"]674[/TD]
[TD="width: 64, bgcolor: transparent"][/TD]
[TD="width: 64, bgcolor: transparent"][/TD]
[TD="width: 64, bgcolor: transparent"]1[/TD]
[TD="width: 64, bgcolor: transparent, align: right"]106.00%[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, align: right"]2[/TD]
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent, align: right"]701.5[/TD]
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent"]2[/TD]
[TD="bgcolor: transparent, align: right"]79.50%[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, align: right"]3[/TD]
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent, align: right"]736.2[/TD]
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent"]3[/TD]
[TD="bgcolor: transparent, align: right"]102.70%[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent, align: right"]4[/TD]
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent, align: right"]778.2[/TD]
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent"]4[/TD]
[TD="bgcolor: transparent, align: right"]111.00%
[/TD]
[/TR]
</tbody>[/TABLE]
I want to use VLOOKUP to enter formulae into the G column using VLOOKUP, and multiply the result by the values in column Fbut can not get it to work in VBA.
The code I have tried is:
Sub lookuptest1()
Dim i As Long
Dim lookup_range As Range
Set lookup_range = Range("I3:J6")
Range("G3").Select
For i = 0 To 3
ActiveCell.Offset(i, 0).FormulaR1C1 = "=RC[-1]*vlookup(RC[-5],lookup_range,2)"
Next
Could somebody help me please?