+ Reply to Thread
Results 1 to 7 of 7

next available row coding issue

  1. #1
    Registered User
    Join Date
    05-10-2013
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    11

    next available row coding issue

    Hi All

    I know there are a number of posts on this, but I can not see where this is going wrong. I have tried numerous bits of code but nothing seems to work. I know it must be simple (for someone who really knows what they are doing..... which is not me!).

    I just want to save contents of userform in next available line in worksheet "UserFormDataEntry". Currently it just keeps saving to active worksheet.

    Any help is GREATLY APPRECIATED

    Thanks

    Please Login or Register  to view this content.
    Last edited by JAL_0110; 05-21-2013 at 03:18 AM.

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: next available row coding issue

    Can you also attach the sheet you are using?

    What is Input1, Input2, etc? The names of the text boxes?

    To Attach a File:

    1. Click on Go Advanced
    2. In the frame Attach Files you will see the button Manage Attachments
    3. Click the button.
    4. A new window will open titled Manage Attachments - Excel Forum.
    5. Click the Browse... button to locate your file for uploading.
    6. This will open a new window File Upload.
    7. Once you have located the file to upload click the Open button. This window will close.
    8. You are now back in the Manage Attachments - Excel Forum window.
    9. Click the Upload button and wait until the file has uploaded.
    10. Close the window and then click Submit.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Registered User
    Join Date
    05-10-2013
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: next available row coding issue

    vsa productivity userform.xlsmHi

    Thanks for the reply.

    Input1 to Input4 = combo boxes
    Input5 to Input156 = Text boxes


    If you are looking at the Private Sub cmdSubmit_Click() code can you please also look at the following code and see if you pick up anthing wrong
    Please Login or Register  to view this content.
    It runs correctly, but once i change the text boxes to be <61, and press 'print and submit' again it still comes up with the error message box and will not submit. For the rest i think it works ok (other than saving to the wrong worksheet).

    Thanks so much again for the help.

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643
    You have no worksheet reference here, so Rng will be referring to A2 on the active sheet.
    Please Login or Register  to view this content.
    Try adding a reference to the appropriate sheet.
    If posting code please use code tags, see here.

  5. #5
    Registered User
    Join Date
    05-10-2013
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: next available row coding issue

    Hi Norie

    I set

    Please Login or Register  to view this content.
    It worked!! Something so simple almost made me go crazy Thank you so much


    If anyone can help with the other query relating to

    Please Login or Register  to view this content.
    (as per above thread)
    it would be greatly appreciated.

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643
    Textboxes contain text values, so to add there values arithmetically you need to convert the text to numbers.

    There are various conversion functions you can use, eg CLng, CInt, Val etc

    In this case I think CLng might be what you want, that will convert to Long which is the same data type as the variable you want to store the result in.

    By the way, you could considerably shorten the first code you posted using loops and the Controls collection of the userform.
    Last edited by Norie; 05-21-2013 at 05:39 AM.

  7. #7
    Registered User
    Join Date
    05-10-2013
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: next available row coding issue

    Hi Norie

    Thanks for the reply.

    I dont doubt that I make the code much harder than it needs to be. I only started this a few weeks ago and I am really still just learning. I hope I get to that stage one day.

+ 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