Djblois
05-24-2007, 01:20 PM
I am trying to use a variable in a v-lookup formula, is this possible?
Instead of this:
Sub comAddWhse(ByVal rngToAdd As Range)
rngToAdd.FormulaR1C1 = _
"=VLOOKUP(RC[-1],'[BusinessReportingReference.xls]Whses'!C1:C8,2,FALSE)"
rngToAdd.Value = rngToAdd.Value
End Sub
I want to use this code:
Sub comAddWhse(ByVal rngToAdd As Range, ByVal intColumnDiff As Integer)
rngToAdd.FormulaR1C1 = _
"=VLOOKUP(RC[intColumnDiff],'[BusinessReportingReference.xls]Whses'!C1:C8,2,FALSE)"
rngToAdd.Value = rngToAdd.Value
End Sub
right now it just crashes, is there another way to get the same effect? The reason why I am doing this is I use that formula multiple times and each time the Column difference is different.
Instead of this:
Sub comAddWhse(ByVal rngToAdd As Range)
rngToAdd.FormulaR1C1 = _
"=VLOOKUP(RC[-1],'[BusinessReportingReference.xls]Whses'!C1:C8,2,FALSE)"
rngToAdd.Value = rngToAdd.Value
End Sub
I want to use this code:
Sub comAddWhse(ByVal rngToAdd As Range, ByVal intColumnDiff As Integer)
rngToAdd.FormulaR1C1 = _
"=VLOOKUP(RC[intColumnDiff],'[BusinessReportingReference.xls]Whses'!C1:C8,2,FALSE)"
rngToAdd.Value = rngToAdd.Value
End Sub
right now it just crashes, is there another way to get the same effect? The reason why I am doing this is I use that formula multiple times and each time the Column difference is different.