+ Reply to Thread
Results 1 to 13 of 13

VBA Code to have UserForm input data into Worksheet

  1. #1
    Registered User
    Join Date
    02-22-2019
    Location
    Michigan, USA
    MS-Off Ver
    MS 2010
    Posts
    49

    VBA Code to have UserForm input data into Worksheet

    Hello all,

    I am creating a UserForm to input data into a worksheet. After putting together the form and trying to use lastrow to and the data into the sheet I get back (Run-time error '1004': Application-defined or object-defined error). I have never used VBA coding before so I'm very green on all the terminology. I checked to make sure the sheets were spelled correctly. If anyone could help it would be much appreciated. My sheet name is (SOL). My code is below:



    Please Login or Register  to view this content.
    Last edited by Likayuu19; 02-22-2019 at 02:51 PM.

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

    Re: VBA Code to have UserForm input data into Worksheet

    Your post does not comply with Rule 2 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Click on Edit to open your thread, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 6)
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Registered User
    Join Date
    02-22-2019
    Location
    Michigan, USA
    MS-Off Ver
    MS 2010
    Posts
    49

    Re: VBA Code to have UserForm input data into Worksheet

    Fixed now I know for next time thank you

  4. #4
    Registered User
    Join Date
    11-09-2018
    Location
    USA
    MS-Off Ver
    365
    Posts
    59

    Re: VBA Code to have UserForm input data into Worksheet

    I was able to get it to work, by removing the Sheets("SOL"). See abbreviated code below.

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    02-22-2019
    Location
    Michigan, USA
    MS-Off Ver
    MS 2010
    Posts
    49

    Re: VBA Code to have UserForm input data into Worksheet

    I am still getting the same error in line

    Please Login or Register  to view this content.

  6. #6
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,071

    Re: VBA Code to have UserForm input data into Worksheet

    You have a 1 (number one) in xlup rather than an l (lower case L)

  7. #7
    Registered User
    Join Date
    11-09-2018
    Location
    USA
    MS-Off Ver
    365
    Posts
    59

    Re: VBA Code to have UserForm input data into Worksheet

    Sorry-forgot to mention that I changed .text to .value. Not sure if that will help. I'm not much of an expert myself.

  8. #8
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: VBA Code to have UserForm input data into Worksheet

    At a quick glance that looks like a number one intead of letter "L" in (xlUp)

    I usually do prefer to reference the sheet unless the code GUARANTEES that the sheet in question will be active. So I'd leave in Sheets("SOL"). and just fix the 1 vs L problem
    Last edited by Arkadi; 02-22-2019 at 03:06 PM.
    Please help by:

    Marking threads as closed once your issue is resolved. How? The Thread Tools at the top
    Any reputation (*) points appreciated. Not just by me, but by all those helping, so if you found someone's input useful, please take a second to click the * at the bottom left to let them know

    There are 10 kinds of people in this world... those who understand binary, and those who don't.

  9. #9
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,071

    Re: VBA Code to have UserForm input data into Worksheet

    I agree with Arkadi about the sheet reference & I would use something like
    Please Login or Register  to view this content.
    Otherwise if SOL is not the active sheet, you'll calculate the last row on one sheet & use that on another sheet entirely, giving unexpected results.

  10. #10
    Registered User
    Join Date
    02-22-2019
    Location
    Michigan, USA
    MS-Off Ver
    MS 2010
    Posts
    49

    Re: VBA Code to have UserForm input data into Worksheet

    Thank you all for your generous help. The code works now.

  11. #11
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: VBA Code to have UserForm input data into Worksheet

    Thanks for the rep Likayuu19, glad we could help

    Please remember to mark the thread as solved if your issue is resolved? Thanks in advance!

  12. #12
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,071

    Re: VBA Code to have UserForm input data into Worksheet

    You're welcome & thanks for the feedback.

    Beaten to it again by Arkadi

  13. #13
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: VBA Code to have UserForm input data into Worksheet

    @Fluff13... Lol it's not a race my friend. And if it were, you beat me generally. I look at it as good teamwork

+ 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. Get data from userform to input into specific worksheet with named range
    By Mark Dynes in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 03-17-2017, 12:18 PM
  2. [SOLVED] Userform to input data in a hidden worksheet
    By jmsb in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 05-14-2013, 08:09 PM
  3. Replies: 4
    Last Post: 11-28-2012, 06:09 PM
  4. Code to write data from userform to worksheet not working
    By Lothar69 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-05-2011, 03:28 PM
  5. VBA code to copy data from text box and input into a cell in another worksheet
    By bobaftt in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-29-2011, 01:49 AM
  6. Userform Textbox to input data to worksheet
    By wrobs in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 06-23-2010, 01:02 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