TextBox in UserForm only populates on pressing enter.

  • I have UserForm with three ComboBoxes (PropertyName,HouseNumber,HotelNumber) that have hard coded options and I have a few TextBoxes (Rent) that I need to populate when a value is selected from each ComboBox. It currently only works when I press enter for each TextBox.




    The Code repeats with all options and ends with


    Code
    End If
    End Sub


    I have tried Changing the Rent_Enter to something else but then it doesn't work at all. Nothing in this UserForm pulls from a spreadsheet. I'm only using it to reference predetermined static values.


    I'm sorry if this is hard to read I absolutely know nothing about VBA everything I have done is from 3 weeks of google searching.

  • Here is the code for the UserForm itself.



    Each ComboBox does not have any code at all


    The only other code is the code for the text box which is what I originally posted. When the options from the ComboBox are selected I need it to push an update to the TextBox within the same UserForm.


    I hope this helps since I don't know what I'm doing its hard to relay what I'm thinking to a way you can understand.

  • How would I do that? By array do you mean in code? I'm not familiar with VBA at all. I have all of the property information in the code. I just need to be able to have the userform pull the values from the code based on the criteria of the 3 command boxes and input it into text boxes. The code i have works but only when I click on each text box individually and press enter. What I would like to happen is the user form is opened via command button on spreadsheet. The user will select the property being referenced then select how many houses then select how many hotels and then the textbox will spit out how much rent is due within the user form. Everything works except for having to click enter on the textbox. This annoying because I have three other textboxes and have the same problem. Is their a way I can code the text box to look for changes in the comboxes and adjust accordingly?

  • The same thing I did for the one textbox can be done to the other three text boxes.
    what are the other text boxes?


    your spread sheet would be helpful.


    P.S.
    You forgot Tennesse in your list

  • my apologies when I viewed your document it was on my phone and I had no idea you had macros. would you like the full document or the bit about the user form? The full document is a bit messy and I'm trying to learn ways to clean it up and make it work better but like I said before I'm learning everything I'm doing through google and I'm 3 weeks in.

  • On an additional note I was playing around with your example and my version of monopoly has altered or house rules so to speak that allows up to 10 houses AND 10 hotels on a single property. I would need to be able to include that into the code I might just go with the spreadsheet idea it seems like it would be easier and it looks like you put a lot of work into it. I just didn't want anyone to be able to mess up the document but I can always hide and protect it.

  • sorry about the number of houses and hotels, I just assumed you were using the normal monopoly game setup


    the spread sheet is MUCH easier to do. (simply hide and protect it)


    Since you are not following the normal monopoly game (Eg: you are using 10 houses and 10 hotels)
    I would need you to provide me with:
    rents for each property
    rents for each House
    rents for each Hotel
    price with no houses and hotels
    price per house
    price per hotel
    mortgage per property


    I would require this to determine what kind of formula I would need.
    If the rents are consistent eg: 1 house = 10 2 house = 20 3 house = 30
    (the same for hotels)
    then the I can use a formula to calculate it.
    otherwise I would have to fill the speadsheet with all of them


    If you could provide me with this info I can let you know

  • I appreciate your hard work however I am still only able to choose between houses or hotels
    ex. I pick 10 houses and 1 hotel, the 10 houses changes to 0 and hotel stays at one.


    I need to be able to use a combination of houses and hotels.

  • That's why I started this project to learn VBA. I relate to games so creating a game based VBA project seemed like a good idea. I really want to learn this stuff and be able to assist others. The rules arn't that much different from normal monopoly the only real change is the house and hotels and there is unlimited money in the bank so to speak. I do appreciate you helping me ive been going over your code trying to figure it just for a knowledge aspect. There is only one other thing I need help with and I will be done with this project. It is not related to the userform at all if you wouldn't mind helping me with it. Due to space constraints the houses and hotels are actually pictures labeled 1-10 for each and each number has the image stacked on itself like 40 times. My question is the following is there a way I can use just one picture and when a user tries to drag it a copy is dragged instead?

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!