+ Reply to Thread
Results 1 to 5 of 5

Auto record number - need to delete and re-calculate

  1. #1
    Forum Contributor
    Join Date
    04-14-2013
    Location
    Ky
    MS-Off Ver
    Excel 2013
    Posts
    344

    Auto record number - need to delete and re-calculate

    I have the following code to add a 'record number' in column A, and a 'name" (from a text box entry) in Column B for each new row of data which is input from a userform:

    Please Login or Register  to view this content.
    FYI, my first row of data is constant and cannot be deleted, and begins with a "1" in cell $A$2 (Row 1 is a header and contains other values/data).

    I then have another userform and routine where the any names added in column B (a Range named "NameList") can be deleted, after being selected from a combo box:

    Please Login or Register  to view this content.
    So I may have a sheet that look like this:
    A B
    Header Row...
    1 Former Employee
    2 Bill
    3 Bob
    4 Becky
    5 Beth

    My problem is that I also need to delete the corresponding record number, and if the record number is in the middle, i.e., say "Bob" was deleted from above, that not only would the "3" be deleted, but the records numbers would also shift up and recalculate to the correct number (in this example, "4" would become "3" and "5" would become "4").

    Any help is greatly appreciated!

    -HeyInKy

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Auto record number - need to delete and re-calculate

    Hello HeyInKy,

    Since the record number equals the row number, just add the formula =ROW() to row 2 down. When the row is deleted the formula will recalculate.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Forum Contributor
    Join Date
    04-14-2013
    Location
    Ky
    MS-Off Ver
    Excel 2013
    Posts
    344

    Re: Auto record number - need to delete and re-calculate

    It actually does not equal the row number, but I see where you're going... perhaps ROW()+2 would work?

    Thanks!

  4. #4
    Forum Contributor
    Join Date
    04-14-2013
    Location
    Ky
    MS-Off Ver
    Excel 2013
    Posts
    344

    Re: Auto record number - need to delete and re-calculate

    Worked! Thanks!

    Follow-up question... what would my VBA code look like to find the last cell in the column with a value and then delete that value?

    Please Login or Register  to view this content.
    ??

  5. #5
    Forum Contributor
    Join Date
    04-14-2013
    Location
    Ky
    MS-Off Ver
    Excel 2013
    Posts
    344

    Re: Auto record number - need to delete and re-calculate

    This seemed to work:
    Please Login or Register  to view this content.

+ 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. [SOLVED] formula to auto delete number in dropdown list when number appears in another cell #2
    By ddevins in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-28-2014, 08:31 AM
  2. [SOLVED] formula to auto delete number in dropdown list when number appears in another cell
    By ddevins in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 04-28-2014, 04:54 AM
  3. Replies: 4
    Last Post: 12-17-2012, 10:14 AM
  4. Auto Assign the next available number to a record in a spreadsheet.
    By tommytiger1972 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-07-2011, 01:44 AM
  5. auto populate a record based upon a value in previous record.
    By leewcrawford in forum Access Tables & Databases
    Replies: 4
    Last Post: 04-07-2009, 11:41 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