Increment ID without duplication when a new row inserted

Prescience

New Member
Joined
May 29, 2023
Messages
4
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
I am building on from a table seating planner I recently found, and want to make the process as user friendly as possible for anyone not too familiar with Excel. I have a small issue that is driving me mad, as I can't seem to find the right approach to fix the problem.

Using the code below in a table, works fine, until you insert a new line or lines, which results in duplication of the UnusedID. I'd like to find a way for a user to insert new rows and the row number increment. Currently they have to manually select and drag to the bottom of the list to resolve any duplicated UnusedID numbers.

=IF(C2="--",SUM(MAX(D$1:D1),1),"") code works without issue until you 'insert' a new line.

Can someone provide an adjustment to the code above to ensure when a new row is entered we don't see duplicated UnusedID's as shown in the image below?

Thanks in advance for your knowledge and support.
 

Attachments

  • Screenshot 2023-05-29 at 16.18.06.png
    Screenshot 2023-05-29 at 16.18.06.png
    49.2 KB · Views: 26

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Try

Excel Formula:
=IF(C2="--",ROWS($D$2:D2),"")
 
Upvote 0
In what way it fails?
What results it gives and what you want as result.
can you post some expected results? using xl2bb.
 
Upvote 0
In what way it fails?
What results it gives and what you want as result.
can you post some expected results? using xl2bb.
Sorry for the delayed response. I have been busy and not had a chance to explore further.

The code is missing the SUM MAX element that is required. This, while your code to insert row numbers works, the actual code fails. I am not sure how to describe any further and so have taken another route, which works, although not ideal.
 
Upvote 0
Original issue.

=IF(C2="--",SUM(MAX(D$1:D1),1),"") code works without issue until you 'insert' a new line.

Below is the solution.

=IF(C2="--", SUM(MAX(INDIRECT("D$1:D" & ROW()-1))+1), "")
 
Upvote 0
Solution

Forum statistics

Threads
1,224,823
Messages
6,181,175
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top