+ Reply to Thread
Results 1 to 3 of 3

Changing texbox value based on VLOOKUP result

  1. #1
    Registered User
    Join Date
    01-11-2005
    Posts
    64

    Cool Changing texbox value based on VLOOKUP result

    Hi all,

    I'm trying to build a very simple macro that returns the exchange rate based on the two inputs from the user - the currency they're selling and the currency they wish to buy. I know that this tool can very simply be built in Excel without resorting to VBA, but for other reasons I need to have it in VBA. So here are the facts:

    - I have created a UserForm with two ComboBoxes and one TextBox
    - The first ComboBox (cmbCCY1) is for the user to choose the currency they're selling adn the second ComboBox (cmbCCY2) is for the the user to choose the currency they wish to buy
    - The TextBox (txtFXrate) is waiting for the Change trigger from cmbCCY1 and once it is triggered it should combine the values from both ComboBoxes and VLOOKUP the rate for the currency combination from the pre-populated table sitting on worksheet "Rates".

    Here is the code I have so far:

    Please Login or Register  to view this content.
    However, when I run I get an error. I'm pretty sure where I'm going wrong is with the syntax of the lookup value. To derive the lookup value I have to use the values of both ComboBoxes. For example, if the user chooses USD value in first ComboxBox and then EUR in the second ComboBox, my lookup value needs to be USDEUR to enable me to carry out the lookup.

    Please help - thanks

  2. #2
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Changing texbox value based on VLOOKUP result

    anar_baku,

    You have "cmbCCY1.Value" & "cmbCCY2.Value". The quotes shouldn't be there, and I'd recommend using .Text instead of .Value for this:
    Please Login or Register  to view this content.


    Hope that helps,
    ~tigeravatar

  3. #3
    Registered User
    Join Date
    01-11-2005
    Posts
    64

    Cool Re: Changing texbox value based on VLOOKUP result

    Quote Originally Posted by tigeravatar View Post
    anar_baku,

    You have "cmbCCY1.Value" & "cmbCCY2.Value". The quotes shouldn't be there, and I'd recommend using .Text instead of .Value for this:
    Please Login or Register  to view this content.


    Hope that helps,
    ~tigeravatar
    Thanks for the response tigeravatar.

    I did try your code, however, I get a "Run-time error 424 - Object required"

    Help please!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1