VLOOLUP In VBA Userform

Faiek

New Member
Joined
May 2, 2011
Messages
48
Hi,
I'd like to implement A Previously used VLOOKUP function in a VBA Form. How can I Make a Textboxes's Value equal to the VLOOKUP Value? Also The VLOOKUP Formula I Used Is:
Code:
VLookup(C4, Crossreftable, 3, False)
I Want to Change the C4 to The Value of Another Textbox, How can I Do that?

Thanks,
Faiek
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Try something like this...

Code:
Range("A2").Value = Application.VLookup(UserForm1.TextBox1.Value, Range("Crossreftable"), 3, 0)

or

Code:
[font=Courier New][color=darkblue]Dim[/color] LookupResult [color=darkblue]As[/color] [color=darkblue]Variant[/color]

LookupResult = Application.VLookup(UserForm1.TextBox1.Value, Range("Crossreftable"), 3, 0)
[/font]
 
Upvote 0
Thanks So Much!
Can you please also advise how to use this formula in the same way as the other one?
Code:
INDEX('Cross-Ref'!$C$12:$C$482,MATCH(Search!$C4,'Cross-Ref'!$B$12:$B$482,0))
Thanks
 
Upvote 0
Try...

Code:
Range("A2").Value = Application.Index(Worksheets("Cross-Ref").Range("C12:C482"), Application.Match(UserForm1.TextBox1.Value, Worksheets("Cross-Ref").Range("B12:B482"), 0))

or

Code:
[font=Courier New][color=darkblue]With[/color] Application
    Range("A2").Value = .Index(Worksheets("Cross-Ref").Range("C12:C482"), .Match(UserForm1.TextBox1.Value, Worksheets("Cross-Ref").Range("B12:B482"), 0))
[color=darkblue]End[/color] [color=darkblue]With[/color][/font]
 
Upvote 0

Forum statistics

Threads
1,224,560
Messages
6,179,520
Members
452,921
Latest member
BBQKING

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