+ Reply to Thread
Results 1 to 15 of 15

Input Data using Forms

  1. #1
    Registered User
    Join Date
    11-08-2011
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2007
    Posts
    12

    Input Data using Forms

    Hi everyone,

    This is my first time on here so have patience lol.

    I have a problem where I have a userform to input data into sheet 2. I am having trouble making it paste in the next row. If I only have data in collum B and then I submit the form again to put data in collum A it overwrites the data in collum B instead of going to the next completely empty row.

    Here is my current code I have been trying to work with.



    Please Login or Register  to view this content.
    Last edited by cneff; 11-09-2011 at 02:18 AM.

  2. #2
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Input Data using Forms Help!

    Hi cneff

    Is Column B populated and is Column A NOT populated? Without seeing your data it's difficult to recommend but try this for Next Row
    Please Login or Register  to view this content.
    John

    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.

  3. #3
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591

    Re: Input Data using Forms Help!

    solution same as one already posted....

  4. #4
    Registered User
    Join Date
    11-08-2011
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: Input Data using Forms Help!

    Thanks for getting back so quick.

    It came back with

    Run-time error '91':

    Object variable or With block variable not set

  5. #5
    Registered User
    Join Date
    11-08-2011
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: Input Data using Forms Help!

    further to your previous response -

    yes Column B is sometimes populated where Column A is not. sometimes It could be column C or D ect with combinations also

  6. #6
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Input Data using Forms Help!

    Hi cneff

    Put this code in a separate general module.
    Please Login or Register  to view this content.
    Does it return the Row you're looking for?

  7. #7
    Registered User
    Join Date
    11-08-2011
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: Input Data using Forms Help!

    Hi John,

    I know this may sound silly but what and where is a separate general module

  8. #8
    Registered User
    Join Date
    11-08-2011
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: Input Data using Forms Help!

    I ran it in a separate module but it came up with the same error

  9. #9
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Input Data using Forms Help!

    Hi cneff

    Open your workbook and enable macros. Open VBA (Alt + F11). VBA will open. In the Menu Bar (top of the screen) select Insert-->Module. That will open a window on the right hand side of the screen. Copy this code
    Please Login or Register  to view this content.
    Paste the code in the right hand screen. Make certain "Option Explicit" doesn't appear twice...if it does delete one of the occurrences of "Option Explicit".

    Put your cursor on this line of code
    Please Login or Register  to view this content.
    Now, step through the code (click on "F8" key)...as you click "F8" each line of code will execute. Let me know what the message box says.

  10. #10
    Registered User
    Join Date
    11-08-2011
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: Input Data using Forms Help!

    It came up with the same error as before

    Run-time error '91':
    Object variable or With block variable not set
    after hitting F8 on

    NextRow = Cells.Find("*", Cells(Rows.Count, Columns.Count), SearchOrder:=xlByRows, _
    SearchDirection:=xlPrevious).Offset(1, 0).Row

  11. #11
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Input Data using Forms Help!

    Hi cneff

    Sorry...you were posting as I was composing. If you're still getting the error message then I need to see your file (with code) so I can "see" what's going on.

  12. #12
    Registered User
    Join Date
    11-08-2011
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: Input Data using Forms Help!

    I have attached the workbook.

    I havent finished the macro for all the form yet but It will all fall into place once it can submit to the next completely empty row
    Attached Files Attached Files

  13. #13
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Input Data using Forms

    Hi cneff

    Don't pretend to know what you're trying to do...this code change appears to add data to the next available row
    Please Login or Register  to view this content.
    Let me know what's not working as you require.
    Attached Files Attached Files

  14. #14
    Registered User
    Join Date
    11-08-2011
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: Input Data using Forms

    Hi John,

    Thanks it works a treat.

    I really appreciate your help

  15. #15
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Input Data using Forms

    Hi cneff

    You're welcome...glad I could be of help. If that satisfies your need, I'd appreciate it if you'll please mark your thread as "Solved".
    To mark your thread solved do the following:
    - Go to your first post on the thread
    - Click edit
    - Click Advance
    - Just below the word "Title:" you will see a dropdown with the word No prefix.
    - Change to Solved
    - Click Save

+ 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