+ Reply to Thread
Results 1 to 18 of 18

Capturing data from userform into the workbook

  1. #1
    Forum Contributor
    Join Date
    08-29-2011
    Location
    Wisbech England
    MS-Off Ver
    Excel 2010
    Posts
    308

    Capturing data from userform into the workbook

    Hi
    Can someone help me please to write a code to capture everything from user form into the workbook
    I only starting to learn about VBA coding and know a little bit :-) but this is to advance for me...
    I need this for work and would appreciate you help.
    Thanks
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Capturing data from userform into the workbook

    This code will save all your data into row 1 of your spread sheet.


    Please Login or Register  to view this content.

  3. #3
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Capturing data from userform into the workbook

    An improved and faster method is:-

    Instead of saving the data onto the spreadsheet, save it into an array.

    Then you can move the data around within the array.

    Then write the array into excel. This is one write instruction and therefore fast.

  4. #4
    Forum Contributor
    Join Date
    08-29-2011
    Location
    Wisbech England
    MS-Off Ver
    Excel 2010
    Posts
    308

    Re: Capturing data from userform into the workbook

    Not really surer what you mean????
    Tahnks

  5. #5
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Capturing data from userform into the workbook

    Please Login or Register  to view this content.
    Attached Files Attached Files

  6. #6
    Forum Contributor
    Join Date
    08-29-2011
    Location
    Wisbech England
    MS-Off Ver
    Excel 2010
    Posts
    308

    Re: Capturing data from userform into the workbook

    Hi
    Now I am slowly getting it :-)
    Is it possible to have a data from the combo boxes and textboxes to appeared in a specific columns?
    Also why in some columns it says TRUE and FALSE?
    And is it possible to add data from this userform in the next empty row?
    I appreciate your help and support.

  7. #7
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Capturing data from userform into the workbook

    Just loop through your array and replace the unwanted text with "".

    Dimension your array to the maximum column size minus 1. Arrays start at 0, columns at 1.

    then manipulate your array before writing it to excel like I demonstrated:-

    'Manipulate columns like this:-

    Please Login or Register  to view this content.
    To write to the next empty row. assuming your column a is always used.

    replace this line:-
    Please Login or Register  to view this content.
    with:-

    NextRow = Range("A1").End(xlDown).Offset(1, 0).Row
    Range(Cells(NextRow, 1), Cells(NextRow, 13)).Value = myArray

  8. #8
    Forum Contributor
    Join Date
    08-29-2011
    Location
    Wisbech England
    MS-Off Ver
    Excel 2010
    Posts
    308

    Re: Capturing data from userform into the workbook

    Hi
    I am getting the following error with this line of code
    Please Login or Register  to view this content.
    "Application defined or object defined error"

  9. #9
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Capturing data from userform into the workbook

    yes I had that sometimes today.

    That line is looking for the first blank row in A, for some reason " A Bug" it selects that last row that excel suports
    then it is trying to select the next row to that, hence the error.

    The best thing to do is to restart excel

  10. #10
    Forum Contributor
    Join Date
    08-29-2011
    Location
    Wisbech England
    MS-Off Ver
    Excel 2010
    Posts
    308

    Re: Capturing data from userform into the workbook

    Hi
    I have followed your instructions but I am still getting the same error????
    Thanks

  11. #11
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Capturing data from userform into the workbook

    try replacing that line with

    nextrow = Selection.SpecialCells(xlCellTypeLastCell).row

    if you still get the error

    then delete that line

    close excel

    re open the file

    re-enter the line

  12. #12
    Forum Contributor
    Join Date
    08-29-2011
    Location
    Wisbech England
    MS-Off Ver
    Excel 2010
    Posts
    308

    Re: Capturing data from userform into the workbook

    After following your instructions I'm getting error with another line of code
    Please Login or Register  to view this content.

    Please see the example
    Attached Files Attached Files

  13. #13
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Capturing data from userform into the workbook

    So you added an image to the userform.


    This line needs changing:-
    Please Login or Register  to view this content.

  14. #14
    Forum Contributor
    Join Date
    08-29-2011
    Location
    Wisbech England
    MS-Off Ver
    Excel 2010
    Posts
    308

    Re: Capturing data from userform into the workbook

    Ok we are getting there... It worked ok this time however when it puts the data in the first row first time, the second time I'm trying to do it doesn't record data in the next empty row it replaces data in previous row. does this make sense?

  15. #15
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Capturing data from userform into the workbook

    Add
    Please Login or Register  to view this content.
    to the macro as shown


    Please Login or Register  to view this content.

  16. #16
    Forum Contributor
    Join Date
    08-29-2011
    Location
    Wisbech England
    MS-Off Ver
    Excel 2010
    Posts
    308

    Re: Capturing data from userform into the workbook

    Thank you for your help!!
    Last edited by ciapul12; 11-26-2013 at 05:06 PM.

  17. #17
    Forum Contributor
    Join Date
    08-29-2011
    Location
    Wisbech England
    MS-Off Ver
    Excel 2010
    Posts
    308

    Re: Capturing data from userform into the workbook

    This worked grate and I want to thank you for your help!! Can I ask for 1 more thing? You remember when you have mentioned about manipulating my array to get the data to a specific cells? It didn't work I have tried everything and every time I tried I failed... I am getting data all over the place but this isn't the biggest issue, the biggest problem is that it doesn't record all data from userform only some data plus I am still getting True and False in certain cells how can I fix all does little problems???
    Would it be possible to have something that would create a Number in column A, every time new entry is made for example:
    1
    2
    3
    4
    5
    6
    and so on...
    Thank you and apologize for being a pain...
    Dan

  18. #18
    Forum Contributor
    Join Date
    08-29-2011
    Location
    Wisbech England
    MS-Off Ver
    Excel 2010
    Posts
    308

    Re: Capturing data from userform into the workbook

    I will appreciate anyone's help with the above please.
    Another issue I'm having with it is that when I for example do 4 entries and delete them the next entry wouldn't be in next empty row instead data will be in row 4 and continue 5,6,7 and so on however if I delete data again and complete the form then data will be put in row 10,11,12 and so on... This is strange as all above rows are empty??
    Thanks
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] userform data capturing in next available row
    By ciapul12 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-21-2013, 05:24 PM
  2. [SOLVED] Capturing open workbook as variable?
    By aaron.irvine in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-11-2013, 04:34 AM
  3. Replies: 2
    Last Post: 04-14-2013, 05:27 AM
  4. Capturing data from a userform to a worksheet
    By goldbeje in forum Excel General
    Replies: 0
    Last Post: 08-29-2012, 07:22 PM
  5. Replies: 3
    Last Post: 10-18-2011, 11:30 AM

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