VBA Vlookup with Dynamic Data Table Range

BYUIStudent

New Member
Joined
Jun 25, 2015
Messages
10
Hello all. First off thank you so much for all your help. Mr. Excel and your forums has helped me out so much. I am still in the very beginnings of understanding VBA so please forgive my ignorance on certain topics.


This is what I am trying to do.

I am trying to set a cell to =Vlookup($C20,Dynamic table aray,2)

The table array will always be different

This is what i am trying to use

Function VLookUP()
Dim StockTableRange As Range


Sheets("Stock Names").Select
Range("Home").Offset(1, -1).Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
Set StockTableRange = Selection


Sheets("Raw Data").Select


Range("RawDate").Offset(1, 1).Select
activecell = "=vlookup($c20,StockTableRange,2)"




End Function


Thank you for your time and your efforts

BYUIstudent.
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Note ---always try to avoid select thing

Code:
Sub D_vlookup()
Dim lr, cl2, Cl As Long
Dim myrnage As Range


lr = Range("Home").Row + 1
cl2 = Range("Home").Column
Cl = Range("Home").End(xlToRight).Column - 1




 Set myrange = Range(Cells(lr, cl2 - 1), Cells(Rows.Count, Cl))


lookup_result = WorksheetFunction.VLookup("search type here", myrange, 2, 0)


End Sub
 
Upvote 0

Forum statistics

Threads
1,213,544
Messages
6,114,249
Members
448,556
Latest member
peterhess2002

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top