PDA

View Full Version : vlookup in Vba + preventing tabulations in a form field



choubix
07-17-2008, 01:11 AM
hi,

posted my pb on another board but seems people are loosing interest (even though I believe the solution is quite easy :( )

I need to use Vlookups extensively in my project and it seems to be a problem for me to get it to work...

in the following code: tb_Valoren is a Textbox that the user has to fill up in a form. when the user submits the form I need to get the currency for this valoren.

if i hard code an existing valoren in the following code the function works...

wsTrades.Cells(Pointer, 6) = Application.WorksheetFunction.VLookup("& tb_Valoren.Value &", [db_SecValoren], 6, False)


the valoren can be either numeric or in this form : 123456789.abc123

hope someone can help me out there :)

thanks!


ps: is it possible to prevent the user from using the tabulation (Tab) in a form field?

thanks!

Bob Phillips
07-17-2008, 01:38 AM
So what is wrong with the solution that I gave you here (http://www.vbaexpress.com/forum/showthread.php?t=20789&highlight=valoren)

choubix
07-17-2008, 03:34 AM
managed to get the vlookup to work using the array in which the data was stored...


still I have a problem:
the user fills up TextboxA, is it possible to update Textbox B automatically? (without the user having to click anything)

I am using a Vlookup this way:

tb_Valoren.Value = ActiveCell
tb_BbrgCode = Application.WorksheetFunction.VLookup(tb_Valoren.Value, [db_SecValoren], 5, False)

it works only if the user has activated the cell on the worksheet. not when the user fills in the textbox tb_Valoren

any idea?

is it possible to prevent the user from using the Tab key inside a textbox??

thanks!