+ Reply to Thread
Results 1 to 28 of 28

Show data from a selected row in an excel userform

  1. #1
    Forum Contributor
    Join Date
    08-02-2012
    Location
    Austria
    MS-Off Ver
    Excel 2007
    Posts
    457

    Show data from a selected row in an excel userform

    Hi all,

    I wanted to know if it is possible to show the data from cells that are in a choosen row into an excel userform. This way when I select a row (the first cell of a row) and click a button, the userform will open and show me in fields all the information that are on the cells in that row.
    Please let me know if this is clear or need more information to be able to say if it is possible.

    I know how I can add a new row with data filled into fields in the userform, but don't know how to get it back into the userform once selected that row.

    Any help would be great.

    Thanks in advance.
    megatronixs

  2. #2
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,028

    Re: Show data from a selected row in an excel userform

    try this test (click in column A)and see if it helps you
    Attached Files Attached Files
    Regards, John55
    If you have issues with Code I've provided, I appreciate your feedback.
    In the event Code provided resolves your issue, please mark your Thread as SOLVED.
    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

    ...enjoy -funny parrots-

  3. #3
    Forum Contributor
    Join Date
    08-02-2012
    Location
    Austria
    MS-Off Ver
    Excel 2007
    Posts
    457

    Re: Show data from a selected row in an excel userform

    Hello John,

    This is really magic. It works really great :-)
    If I would like to add some buttons to put the current date into the third cell, is that also possible? I was thinking of adding a button next to the text box that once pressed it will show the current date.
    When I click the button ĻupdateĻ does it also saves the data in excel? or do I need to save it when the form closes?

    Thanks a lot for your help :-)

    Greetings,
    megatronixs

  4. #4
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,028

    Re: Show data from a selected row in an excel userform

    Hello megatronixs,
    sure, is possible to add a button for date, for "save" you can save it when you "update"
    Please Login or Register  to view this content.
    when you close the file
    Please Login or Register  to view this content.
    when ...you want.
    I added a button for date and yr file is saved when you update it...!
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    08-02-2012
    Location
    Austria
    MS-Off Ver
    Excel 2007
    Posts
    457

    Re: Show data from a selected row in an excel userform

    Hello John,

    Great help again. It works great. I have one more question. Is it also possible to create reports from the data that would look like the ones in Ms Access? And would it also be possible like in Ms Access to insert the date that is in the text box from the form to the next available cell in the same row? Let's say I have a text field for customer order and in there I put the number of the product ordered, when he orders a second item, it will show below the first one in the userform, but right of the previous one in the sheet.
    Maybe I'm just shooting arrows in the dark, but I don't have access available and lacking the knowledge to do so.

    Greetings and thanks again :-)
    megatronixs

  6. #6
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,028

    Re: Show data from a selected row in an excel userform

    hi man!
    glad I could help you!
    ref yr questions I am sorry, I do not know!

  7. #7
    Forum Contributor
    Join Date
    08-02-2012
    Location
    Austria
    MS-Off Ver
    Excel 2007
    Posts
    457

    Re: Show data from a selected row in an excel userform

    Hello John,

    Thanks a lot. Maybe there is a way to put the information from the cells (filled in with the userform) and print it out that looks like a letter?
    The ultimate goal of the whole thing is to produce a letter with all the data collected in the userform by the click of a button.

    Thank you again for your effort.

    Greetings,
    megatronixs

    ---------- Post added at 11:03 AM ---------- Previous post was at 10:58 AM ----------

    Hello John,

    I just forgot one silly question. Is it possible to implement one more button that could duplicate certain fields into the next row. to avoid filling up the same data a few times. this could be let's say B2, C2,D2 and E2 (as an example).

    Greetings,
    megatronixs

  8. #8
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,028

    Re: Show data from a selected row in an excel userform

    hi
    try thsi
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by john55; 08-17-2012 at 01:38 PM. Reason: cor NextRw2,3...

  9. #9
    Forum Contributor
    Join Date
    08-02-2012
    Location
    Austria
    MS-Off Ver
    Excel 2007
    Posts
    457

    Re: Show data from a selected row in an excel userform

    Hello John,

    Thanks a lot :-)
    These where the building blocks I just needed to get this starting. Now I can finish this super userform.

    Thanks a lot for all your help :-)

    Greetings,
    megatronixs

  10. #10
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,028

    Re: Show data from a selected row in an excel userform

    Hi man,
    you're welcome 'n good luck!

    take care of Lady Gaga, she comes to Vie!

  11. #11
    Forum Contributor
    Join Date
    08-02-2012
    Location
    Austria
    MS-Off Ver
    Excel 2007
    Posts
    457

    Re: Show data from a selected row in an excel userform

    Hello John,

    Sorry to come back again with questions. What if I would like to insert a calendar box in the form. This would be a button that when pressed shows a calendar and after selecting a date, it inserts it in the field. With this I would like to avoid that people start putting there different date formats.

    If I ask to much, please let me know. VBA is still kind of magic to me and finding my way around is not that easy for a beginner :-(

    Thanks in advance,
    megatronixs

    about Lady Gaga, I hope she does not hang to long around here ;-)

  12. #12
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,028

    Re: Show data from a selected row in an excel userform

    Hi, please check the test file!
    I added a calendar for TextBox3, just click it! Hope it helps you!
    Attached Files Attached Files

  13. #13
    Forum Contributor
    Join Date
    08-02-2012
    Location
    Austria
    MS-Off Ver
    Excel 2007
    Posts
    457

    Re: Show data from a selected row in an excel userform

    Woooooooow,

    Thanks John, this is really cool. And if I would like to combine two fields with one button that when I press it, it will insert the today's date and fill in a second field the person pressing the button (the excel user name). I just don't get that part to be filled in. Now I have a second button that when pressed, it puts the user name there, but would be nice to combine those two.

    John, I'm learning VBA as much as possible and discovered the userform some time ago. Can I ask you where did you got the knowledge about userforms? is there a specific book that you can recommend? I would like to be able to do all this by myself without having to bother other people with to many questions.

    BIG thanks for your help, I really appreciate it :-)

    Greetings,
    megatronixs

  14. #14
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,028

    Re: Show data from a selected row in an excel userform

    You can add it, for example for yr Current Date button you can add some text from another TextBox...
    Please Login or Register  to view this content.
    I'm not a programmer at all, I'm learning from here, from there... just read questions, see the solutions provided and test'em!
    see here
    http://www.excelforum.com/excel-gene...additions.html
    http://www.thecodecage.com/forumz/mi...t-excel-forum/
    Last edited by john55; 08-18-2012 at 05:54 AM.

  15. #15
    Forum Contributor
    Join Date
    08-02-2012
    Location
    Austria
    MS-Off Ver
    Excel 2007
    Posts
    457

    Re: Show data from a selected row in an excel userform

    Hello John,

    I know that Application.UserName will put the name of the excel user, but I can't combine that in:

    ws.Cells(iRow, 4).Value = Me.TextBox5.Value 'this is a new textbox and add yr value/text in column 4

    Is there a way to combine these two so it will add both at the same time (date in textbox4 and username in textbox10)?

    Thanks again.

    Greetings
    megatronixs

  16. #16
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,028

    Re: Show data from a selected row in an excel userform

    Please Login or Register  to view this content.

  17. #17
    Forum Contributor
    Join Date
    08-02-2012
    Location
    Austria
    MS-Off Ver
    Excel 2007
    Posts
    457

    Re: Show data from a selected row in an excel userform

    Hello John,

    I just solved :-)
    all I needed to add was this line at the bottom of the code to insert the date:

    Please Login or Register  to view this content.
    Wooow, I start to learn things :-)

    This was some "lessons learned"

    Thanks for all your help.
    Greetings
    megatronixs

    ---------- Post added at 05:40 AM ---------- Previous post was at 05:38 AM ----------

    Hi hi,
    Just did post my last one and then saw your answer :-) Great, thanks
    Last edited by Cutter; 08-19-2012 at 08:25 PM. Reason: Added code tags

  18. #18
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,028

    Re: Show data from a selected row in an excel userform

    hi man,
    Glad you did it!
    next time when you post some code lines please add code tags, I mean add the code between two stuffs like that
    "[ code]" at the beginning and "[/ code]" at the final without " "
    Last edited by john55; 08-18-2012 at 07:44 AM.

  19. #19
    Forum Contributor
    Join Date
    08-02-2012
    Location
    Austria
    MS-Off Ver
    Excel 2007
    Posts
    457

    Re: Show data from a selected row in an excel userform

    Hello John,

    Oops, it is me again :-)

    A silly question. Is it also possible to add a spin control button and let it go up or down a row?
    I was thinking of adding a type of navigation so one could have a quick look trough the clients
    without having to close the form every time.

    Thank you in advance.

    Greetings,
    megatronixs

  20. #20
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,028

    Re: Show data from a selected row in an excel userform

    Hello megatronix,
    I'm sorry, I've never used a spinbutton!

  21. #21
    Registered User
    Join Date
    06-20-2012
    Location
    England
    MS-Off Ver
    Office 365 Excel
    Posts
    62

    Re: Show data from a selected row in an excel userform

    Ignore this post,

    I attempted to do it with

    Please Login or Register  to view this content.
    But it doesnt update the fields in the userform
    Last edited by Steven8294; 08-19-2012 at 06:16 PM. Reason: Invalid post.

  22. #22
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,028

    Re: Show data from a selected row in an excel userform

    hi
    as an option you can use a ListBox, see if it helps you or try to find out how to implement a Spinbutton in yr userform...
    Attached Files Attached Files

  23. #23
    Forum Contributor
    Join Date
    08-02-2012
    Location
    Austria
    MS-Off Ver
    Excel 2007
    Posts
    457

    Re: Show data from a selected row in an excel userform

    Hello John,

    Thanks a lot for this one. I have a small question. On the first column I have the ID number and on the second the client name. I tried to change it so it will fit my needs. but it does behave strange. I will not be able to fish out what to change it easily. I tried to change everything from A to B. but some how I messed it up and canīt get it to work proper. If I would like to add a second listbox with its search field, how can I do this? (the ID number is for the record it self, the client also has a client number). The best way for me to learn is by trying myself, but this is one step to big for me.

    What is actually the function offset do below:

    Please Login or Register  to view this content.

    Sorry for asking to many questions, but I would like to learn and see the code :-)

    Greetings,
    megatronixs

    ---------- Post added at 12:23 PM ---------- Previous post was at 12:20 PM ----------

    Hi there,

    in my above post I did put the code tags, they donīt show up in my monitor :-(
    (the code tags could been seen before I did post it, did I missed something?)

    Sorry for this
    Last edited by Cutter; 08-20-2012 at 07:29 PM. Reason: Corrected code tags

  24. #24
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,028

    Re: Show data from a selected row in an excel userform

    hi,
    try to change the range in Private Sub UserForm-Initialize() too!
    if you want to add the 2nd ListBox you can do it by adding it in yr userform from Toolbox.

    have a look here
    http://www.excelforum.com/forum-rule...rum-rules.html
    Attached Files Attached Files
    Last edited by john55; 08-20-2012 at 02:55 PM.

  25. #25
    Forum Contributor
    Join Date
    08-02-2012
    Location
    Austria
    MS-Off Ver
    Excel 2007
    Posts
    457

    Re: Show data from a selected row in an excel userform

    Hello John,

    Thanks a lot. Finally I managed to do it. I just missed one more group to change the a to b.

    with bellow I noticed that shifting all the "offset" -1. So 0 became -1 and now it works correct as I changed from row A to row B.

    Please Login or Register  to view this content.
    This means that if I add more text boxes, I will have to add the offset values for them as well.

    This forum and especially this thread is turning in a great learning experience !

    Thanks again for the great help and being around when needed :-)

    Greetings,
    megatronixs

  26. #26
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,028

    Re: Show data from a selected row in an excel userform

    hi man,
    glad you learn fast! one day you'll be able to help others!

  27. #27
    Forum Contributor
    Join Date
    08-02-2012
    Location
    Austria
    MS-Off Ver
    Excel 2007
    Posts
    457

    Re: Show data from a selected row in an excel userform

    I also have noticed that if one new row is added (by selecting the row that has no data yet in column A), it will of course not update and it will look strange in the listbox.
    When you exit the userform and return to it, it will be there. (important is to push the "update" button to save the changes.

    I hope many can profit from this thread as it is very good to know more about the power of an excel userform ;-)

  28. #28
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,028

    Re: Show data from a selected row in an excel userform

    You'll discover more 'n more!
    just read carefully as more threads as you can and then for your interest test'em!

  29. #29
    Forum Contributor
    Join Date
    08-02-2012
    Location
    Austria
    MS-Off Ver
    Excel 2007
    Posts
    457

    Re: Show data from a selected row in an excel userform

    Hello John,

    I have one more question for you ;-)
    Is there a possibility to add a button that will go to the next empty row and allow me to add new data?
    and at the same time looking at the previous cell and add +1 to the number (ID number)
    Now to do so, I need to close the form and then select the next empty cell.

    I;m trying to find a solution for this, but some how I don't get it what is needed.

    Thanks in advance,
    megatronixs

  30. #30
    Forum Contributor
    Join Date
    08-02-2012
    Location
    Austria
    MS-Off Ver
    Excel 2007
    Posts
    457

    Re: Show data from a selected row in an excel userform

    Double post per accident

+ 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