• I have a simple project that I need giudence with. Please try not to give the answer... I am trying to learn. Just give me some hints if possible or places in Help I can look.


    I am trying to take and enter data from userform1 into 4 text boxes I created. I want to enter the data in the text boxes and then output that data into cells A1-D1 respective to box order after I click on the command button. Any hints? Thank you.

  • Re: User Form


    Hi


    take this code and put in the commandbutton click section


    Code
    Private Sub CommandButton1_Click()
    Sheets("sheet1").Range("A1") = TextBox1.Value
    'and so on
    End Sub


    HTH


    pangolin

  • Re: User Form


    Ok, that might not work though, because I want to enter in data in the four text boxes and then click on the command box and have that data go to cells A1-D1, THEN I want to continue indefinately entering data in the boxes and every time I want to put that data into the next set of cells down, A2-D2. I was told that I might need to create an Active Event Procedure to clear the Text boxes... Thank you.


    Ok, it just needs to go until I reach D6. Here were my instructions.


    You are to construct a simple data entry spreadsheet. In cell A1, put the string "Last Name". In cell B1, put the string "First Name". In cell C1, put the string "Class". In cell D1, put the string "Zip Code". Then create a Macro/Procedure that will prompt the user to input data for five rows. Create a User Form like the one shown below so that the user can input each row. When the program is finished, you should have a spreadsheet that looks like the second figure below.

  • Re: User Form


    Hi igorati


    I am sure you will appreciate that no one is obliged to do your projects for you and the earlier post did what you wanted....if you had something else in mind then you should have posted that way.....


    Fortunately someone will do it for you as over here hardly any problem remains unsolved


    pangolin

  • Re: User Form


    Yes, much obliged. I understand I am still trying understand how to use VBA. I hope that I can get general ideas and then apply them to my project. It is for school so I don't want to "cheat" but Help can be very crude at times and doesn't provide many examples or the examples I want. Thank you again. :thanx:

  • Re: User Form


    You need to use something like

    Code
    range("a65536").end(Xlup).Offset(1,0)


    to select the next empty cell in column A. You would need to amend this code for your example to search upwards from the last cel that you need to contain data. Also, put an error check in to make sure that the range is not full.

  • Re: User Form



    I want to add a counter for the cmdclick button so that after 5 clicks it stops, which would make it stop at cell D6. How can I do that? And how do I make it error check? Thank you.

  • Re: User Form


    Hi Igorati,


    You said " Please try not to give the answer... I am trying to learn". Cool.


    Learn code tags! <G> Before you post code put [ ] around the word " code " then your code and [ ] around the phrase " /code " after the code. Note:No quotes on the word "code". See the top of the window when you're posting for hints and help. It then displays like this:



    The above is an explanation of what you're currently doing. If you want to do something for a limited number of times, A1 to A6, for example = 6 times you need a For/Next loop. ie:


    For c = 1 to 6
    ...do stuff...
    Next


    Error checking simply means that you put a line that says On Error (do_nothing OR do_something OR go_somewhere) ie:


    'On Error Resume Next' means ignore and keep going.


    'On Error Goto Errorhandler' means skip all code and got to label Errorhandler, which is represented as follows, usually has an 'Exit Sub' statement just before it so it doesn't execute UNLESS and error happens, and usually provides some way or handling the error




    HTH on your search...


    'til


    dr

  • Re: User Form


    Ok, I do realize I need to put explanation in my code. I am going to have to do that next time.


    Ok so I want to make it so that after 5 clicks on the commandbutton1 it will not allow any more clicks. So I guess I need more hints. Because I am not sure what code I would put in for the stuff.


    I was thinking a counter would count the number of clicks and then stop the program or can I make it close the dialog box. I am still thinking how to make it so that if the user enters more data it will not fill in more cells. Thank you for your excellent help thus far.

  • Re: User Form


    Hi,


    Thanks for the tags. Explanations/Comments are also good. Helps the next person that tries to read your code (or you in a year from now) to understand what's happening - from personal experience - its trés important!


    Some more hints:




    Cheers,


    dusty

  • Re: User Form


    Well maybe I wasn't expaining correctly what I wanted to do, but I went a different route What do you think?


  • Re: User Form


    Hi,


    Does it do what you wanted it to do? (most important!)


    This code is untested but it may interest you. Just a slightly different way of doing (what I think) you wanted... your original posts said 5 times max.


    Cheers,


    dr

  • Re: User Form


    I copy and pasted the code but it kept on allowing data to be entered even after the 6th row. Not to worry I got the other one to work. I wonder y it won't accept this one though. I wonder if we have to call the code each time the commandbutton is clicked? Thank you again for your help! You rock!

  • Re: User Form


    This should limit the number of button clicks to 5, I haven't checked the rest of your code

Participate now!

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