+ Reply to Thread
Results 1 to 10 of 10

Increase Number by one in a form once cleared

  1. #1
    Registered User
    Join Date
    01-21-2013
    Location
    Sunshine Coast, Queensland
    MS-Off Ver
    Excel 2003
    Posts
    13

    Increase Number by one in a form once cleared

    I have created a form in Excel which once completed they hit a button that has a macro that takes the information from the form and places it at the bottom of the previous data on another 'data' worksheet - that is working well.
    What I would like to do in one of the cells in the fill in form is take the last number from column B in the 'data' worksheet and increase it by one and place it in the cell on the fill in form automatically. I have tried a macro and could get it to go to the end of the named ranged and right one cell then copy and paste special (ticking add) back on the form worksheet, but then the macro just remembers the last cell I used and doesn't reset to go back to the bottom of the database range once reset? I hope that makes sense - can anyone help?

    thanks
    Karen

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: Increase Number by one in a form once cleared

    Add this code before end sub of the command button Click Code

    Please Login or Register  to view this content.
    Change the name of the Textbox1 and sheet and column references to your requirement.


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Registered User
    Join Date
    01-21-2013
    Location
    Sunshine Coast, Queensland
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Increase Number by one in a form once cleared

    Thanks, I have changed the column ref to B but I am unsure what you mean by changing the name of the Textbox1 to? What would that refer to?

  4. #4
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: Increase Number by one in a form once cleared

    increase it by one and place it in the cell on the fill in form automatically
    Where you would like to show the incremented value? Whether in Form Textbox? Or in the cell of excel sheet?

  5. #5
    Registered User
    Join Date
    01-21-2013
    Location
    Sunshine Coast, Queensland
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Increase Number by one in a form once cleared

    OK, nearly there, it is reading the last date from column A and increasing it by one in column B, but I need it to read the last number in column B, ie it is looking at column A rather than going across to column B? I have changed the letters in the code? I really appreciate your help.

  6. #6
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: Increase Number by one in a form once cleared

    Change it in both the places

    Please Login or Register  to view this content.

  7. #7
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Increase Number by one in a form once cleared

    Hi, Sixthsense,

    quite a perfect example of using constants for the column instead of letters in the code:
    Please Login or Register  to view this content.
    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  8. #8
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: Increase Number by one in a form once cleared

    @ HaHoBe,

    Hm... Yes Nice Indication of the perfect usage

    But I believed OP will aware of the changes since he is already adding data's from userform to sheet

  9. #9
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Increase Number by one in a form once cleared

    Hi, Sixthsense,

    it must have been too early this morning (6:16 a.m. local time), could you please explain why you use the code like you indicated? Correct me if I´m wrong but by using the end command you will refer to a Range, and the standard of range is Value. So why not simplify to
    Please Login or Register  to view this content.
    Ciao,
    Holger

  10. #10
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: Increase Number by one in a form once cleared

    For me your Post #9 Date/Time showing as 01-22-2013 09:59 PM, and I am writing this message to you 01-23-2013 09:29 AM and your's is too early since 12 hours gap.

    Hm... another good catch I don't know why my mind gone for that one where there is no logic when it can be arrived as simple which described in your post #9

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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