billyheanue
Board Regular
- Joined
- Jul 13, 2015
- Messages
- 109
Hi Everyone,
I have rownum and colnum set to a value -- these are row and column coordinates for the FIRST lookup value. However, when I resize the formula to do the next value (which would have coords [rownum +1, colnum], the formula is still doing the vlookup with the same lookup value.
Does anyone know how to incorporate the lookup value's row number increasing by 1 each time, when the formula is resized?
Thank you everyone!
I have rownum and colnum set to a value -- these are row and column coordinates for the FIRST lookup value. However, when I resize the formula to do the next value (which would have coords [rownum +1, colnum], the formula is still doing the vlookup with the same lookup value.
Does anyone know how to incorporate the lookup value's row number increasing by 1 each time, when the formula is resized?
Thank you everyone!
Code:
Private Sub CommandButton8_Click()
Dim rownum As Long
Dim colnum As Long
Dim x As Long
Dim y As Long
Dim colindexval As Double
Dim resizeval As Double
Dim fVLOOKUP As String
rownum = Sheet1.Cells(28, 21).Value
colnum = Sheet1.Cells(27, 21).Value
x = Sheet1.Cells(20, 21).Value
y = Sheet1.Cells(21, 21).Value
resizeval = Sheet1.Cells(19, 12).Value
colindexval = Sheet1.Cells(29, 12).Value
fVLOOKUP = "=VLOOKUP(@1,'@2'!@3,@4,FALSE)"
fVLOOKUP = Replace(fVLOOKUP, "@1", Sheet9.Cells(rownum, colnum).Value)
fVLOOKUP = Replace(fVLOOKUP, "@2", Sheets("Price Data").Name)
fVLOOKUP = Replace(fVLOOKUP, "@3", Sheets("Price Data").Range("A12").CurrentRegion.Address)
fVLOOKUP = Replace(fVLOOKUP, "@4", colindexval)
Sheet9.Cells(y, x).Resize(resizeval, 1).Formula = fVLOOKUP
End Sub