billyheanue
Board Regular
- Joined
- Jul 13, 2015
- Messages
- 109
Hi all,
I am looking for a general theory as to go about using Vlookups with "CurrentRegion" arrays. This is because the lookup table is never strictly defined. That is,
1) The actual lookup table will be the current region of .. say "A37".
2) Have the col_index_number value refer to a literal value IN A SEPARATE CELL (e.g "K99")that is outside the table, and possibly even on a different sheet.
3) And finally, have the lookup value paste in the newly created/formatted column as given by:
I think number 2 is giving me the most trouble. Would I just use
...and then use the variable colValue instead of putting in an actual number when doing the formula in VBA?
Thanks Everyone
I am looking for a general theory as to go about using Vlookups with "CurrentRegion" arrays. This is because the lookup table is never strictly defined. That is,
1) The actual lookup table will be the current region of .. say "A37".
2) Have the col_index_number value refer to a literal value IN A SEPARATE CELL (e.g "K99")that is outside the table, and possibly even on a different sheet.
3) And finally, have the lookup value paste in the newly created/formatted column as given by:
Code:
Private Sub CommandButton3_Click()Set Rng = Range("A37").CurrentRegion
Rng.Select
Selection.Copy
numRows = Selection.Rows.Count
numColumns = Selection.Columns.Count
Selection.resize(numRows + 0, numColumns + 1).Select
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
End Sub
I think number 2 is giving me the most trouble. Would I just use
Code:
dim colValue = cells("K99")
...and then use the variable colValue instead of putting in an actual number when doing the formula in VBA?
Thanks Everyone