+ Reply to Thread
Results 1 to 11 of 11

Input form not saving in the right place

  1. #1
    Registered User
    Join Date
    09-20-2016
    Location
    Scotland
    MS-Off Ver
    2010
    Posts
    7

    Input form not saving in the right place

    HI,

    I attached the file I am having issues.

    to resume the issue I am experiencing,

    I created a workbook with one sheet with rawdata. I have several columns (which have the filter drop down menu). In Column A I have a counter for the first 1000 records (it is empty now I just p`ut the counter with an IF function)(

    Now I created a form and a Save button with some basic VBA code behind it but when I hit save or it saves in the first line under the titles (WHEN the Range is A1 or in the last after the last row with the if counter if the Range is A2(the row with the titles of the columns).

    see below the code, I am using to go to the last cell.
    Sheet1.Activate
    Range("A1").End(xlDown).Offset(1, 0).Select
    ActiveCell.Offset(0, 1).Value = dtpCaseReceivedDate.Value


    I hope some one has a solution to have the save button save on the subsequent empty row instead of overwriting the same line over and over

    Thanks
    Filippo
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor Neil_'s Avatar
    Join Date
    04-19-2013
    Location
    Yorkshire
    MS-Off Ver
    Office 365 Enterprise E3 2013 / 2016
    Posts
    479

    Re: Input form not saving in the right place

    If you bind the ranges to the ControlSource of the text fields as you navigate, you don't need a save button. I've attached an example.
    Attached Files Attached Files
    Last edited by Neil_; 09-20-2016 at 06:49 AM.
    Frob first, tweak later

  3. #3
    Registered User
    Join Date
    09-20-2016
    Location
    Scotland
    MS-Off Ver
    2010
    Posts
    7

    Re: Input form not saving in the right place

    Re: Input form not saving in the right place
    If you bind the ranges to the ControlSource of the text fields as you navigate, you don't need a save button. I've attached an example.
    Attached Files Attached Files
    File Type: xlsm Data Entry Userform example.xlsm‎ (43.8 KB, 0 views) Download

    Hi Neil,

    I have security issues here and I cannot activate macros and my excel level is not enough to understand your answer

    Can you be a bit more explicit please?


    BTW I forgot to tel that I use Excel 2010
    thanks
    Filippo

  4. #4
    Valued Forum Contributor Neil_'s Avatar
    Join Date
    04-19-2013
    Location
    Yorkshire
    MS-Off Ver
    Office 365 Enterprise E3 2013 / 2016
    Posts
    479

    Re: Input form not saving in the right place

    The example has quite a lot of code in it, and pasting it here without the userform to refer to would be of no help. Not sure about the problem you have in running macros when you have attached an xlsm book though.

  5. #5
    Valued Forum Contributor
    Join Date
    06-21-2013
    Location
    Bangladesh
    MS-Off Ver
    Excel 2000, Excel XP, Excel 2002, Excel 2007, Excel 2010, Excel 2013
    Posts
    975

    Re: Input form not saving in the right place

    It would be better if you can use the code like this :
    Please Login or Register  to view this content.
    Because Select, Offset they increase the execution time. Anyway in your code you are using this:
    Please Login or Register  to view this content.
    So this is selecting the row after title row all the time as Range("A1").End(xlDown) is A2 in your sheet.

  6. #6
    Registered User
    Join Date
    09-20-2016
    Location
    Scotland
    MS-Off Ver
    2010
    Posts
    7

    Re: Input form not saving in the right place

    Hi Neil.

    I am in a corporate network. I need to be extra carefull on anything I run here and Macro are blocked by default, except on some documents. Anyway I had IT scan it and authorise it .

    I now see all the code. I will study it to see how to adapt it to my workbook. DO you mind me asking a few question here and there to understand all the controls? thing is I need to understand and use it on my worksheet.

    Thanks!
    Filippo

  7. #7
    Registered User
    Join Date
    09-20-2016
    Location
    Scotland
    MS-Off Ver
    2010
    Posts
    7

    Re: Input form not saving in the right place

    Re: Input form not saving in the right place
    It would be better if you can use the code like this :
    Select Code
    Private Sub CmdSave_Click()
    Sheet1.Activate
    LR = Sheet1.Cells(Rows.Count, "A").End(xlUp).Row
    Sheet1.Range("B" & LR) = dtpCaseReceivedDate.Value
    End Sub
    Because Select, Offset they increase the execution time. Anyway in your code you are using this:
    Select Code
    Range("A1").End(xlDown).Offset(1, 0).Select
    So this is selecting the row after title row all the time as Range("A1").End(xlDown) is A2 in your sheet. You can use A2 here instead of A1 :
    Select Code
    Range("A2").End(xlDown).Offset(1, 0).Select
    Hi Sanram!

    I will try your first suggestion
    Select Code
    Private Sub CmdSave_Click()
    Sheet1.Activate
    LR = Sheet1.Cells(Rows.Count, "A").End(xlUp).Row
    Sheet1.Range("B" & LR) = dtpCaseReceivedDate.Value
    End Sub
    Thanks

  8. #8
    Valued Forum Contributor
    Join Date
    06-21-2013
    Location
    Bangladesh
    MS-Off Ver
    Excel 2000, Excel XP, Excel 2002, Excel 2007, Excel 2010, Excel 2013
    Posts
    975

    Re: Input form not saving in the right place

    You can use
    Please Login or Register  to view this content.

  9. #9
    Valued Forum Contributor
    Join Date
    06-21-2013
    Location
    Bangladesh
    MS-Off Ver
    Excel 2000, Excel XP, Excel 2002, Excel 2007, Excel 2010, Excel 2013
    Posts
    975

    Re: Input form not saving in the right place

    Replace (Rows.Count, "A") with (Rows.Count, "B") in my first suggestion. I didn't see that you have formulas on column A. So it will not work.

  10. #10
    Registered User
    Join Date
    09-20-2016
    Location
    Scotland
    MS-Off Ver
    2010
    Posts
    7

    Re: Input form not saving in the right place

    Quote Originally Posted by sanram View Post
    Replace (Rows.Count, "A") with (Rows.Count, "B") in my first suggestion. I didn't see that you have formulas on column A. So it will not work.
    It works thank you!

  11. #11
    Valued Forum Contributor
    Join Date
    06-21-2013
    Location
    Bangladesh
    MS-Off Ver
    Excel 2000, Excel XP, Excel 2002, Excel 2007, Excel 2010, Excel 2013
    Posts
    975

    Re: Input form not saving in the right place

    You are welcome.

+ 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. Use a second userform in place of an input box help
    By MontgomeryBrea in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-24-2015, 01:49 PM
  2. [SOLVED] Input Box Find Value Offset and place value
    By tjw06d in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-27-2014, 02:02 PM
  3. Data Input Form with number of line items based on user input
    By j_gideon in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-25-2013, 02:54 PM
  4. Excel form to place input into different worksheets
    By chijeff in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-24-2012, 03:35 PM
  5. Looping a data input form based on form option
    By bologne in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 04-17-2011, 03:06 AM
  6. [SOLVED] Trouble with saving user input in an Excel Form.
    By University of Maine student in forum Excel General
    Replies: 0
    Last Post: 03-14-2006, 03:35 PM
  7. Replies: 2
    Last Post: 01-25-2006, 07:50 PM

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