Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello,
I am working with a group of individuals that will be passing around an excel spreadsheet to one another, and wanted to come up with a way to have the 1st column act as an index, with the key component requiring that the index column would automatically re-number itself, if someone entered a new row. A typical value in the first column looks like this: 8-5-012-005 Which in our case means that there are 4 series of number sets, separated by dashes. So the first set is 8, the second 5, the third 012, and the fourth 005. The available range for the sets are 7 or 8 for the first, 5 through 9 for the second, and 0 through 130, and 0 through 200, respectively. So the user can pick any of these ranges for when they decide to create a new record (row). Here is the way the spreadsheet columns currently look (always sorted by Tract_ID): Row-1 Tract_ID Parcel_ID Row-2 7-5-065-105 01245787 Row-3 7-5-112-005 01245787 Row-4 8-5-012-005 01245787 Row-5 8-6-030-125 01245787 Now, here is the way I'd like to have the spreadsheet columns look with the Index_No (can be either Numeric or Text - depending on your recommendations). The sort order is based on 1st, the index number, then 2nd the Tract_ID: Row-1 Index_No Tract_ID Parcel_ID Row-2 1 7-5-065-105 01245787 Row-3 2 7-5-112-005 0126A560 Row-4 3 8-5-012-005 01005147 Row-5 4 8-6-030-125 01000541 Then, let's say the user wants to enter a new value like say, 7-5-105-021. That value would need to go between Row-1 and Row-2, which, if they just inserted the value in the row of their choice, would screw up the indexing. What I need is a way to ALWAYS create an index (automatically), no matter where they decide to put the value in the spreadsheet, AND it would update all of the other Indexes as well (very important requirement). So the end result would be this: Row-1 Index_No Tract_ID Parcel_ID Row-2 1 7-5-065-105 01245787 Row-3 2 7-5-105-021 00547419 Row-4 3 7-5-112-005 5126A560 Row-5 4 8-5-012-005 00005147 Row-6 5 8-6-030-125 00001541 If you need more information, please let me know. TIA for your replies. Phil. BTW, if you are noticing that this was posted in another MS NG, you'd be correct, but I have decided to post here as well, as one of the respondents commented that this might be better done with VBA. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sub BBB()
Dim rng As Range With ActiveSheet Set rng = .Range(.Cells(2, 2), .Cells(2, 2).End(xlDown)) End With Set rng = rng.Offset(0, -1) rng(1) = 1 rng(2) = 2 rng(1).Resize(2, 1).AutoFill rng End Sub Just run it after you have inserted your new row and have completed entering your new data. -- Regards, Tom Ogilvy "Phil" wrote in message ... Hello, I am working with a group of individuals that will be passing around an excel spreadsheet to one another, and wanted to come up with a way to have the 1st column act as an index, with the key component requiring that the index column would automatically re-number itself, if someone entered a new row. A typical value in the first column looks like this: 8-5-012-005 Which in our case means that there are 4 series of number sets, separated by dashes. So the first set is 8, the second 5, the third 012, and the fourth 005. The available range for the sets are 7 or 8 for the first, 5 through 9 for the second, and 0 through 130, and 0 through 200, respectively. So the user can pick any of these ranges for when they decide to create a new record (row). Here is the way the spreadsheet columns currently look (always sorted by Tract_ID): Row-1 Tract_ID Parcel_ID Row-2 7-5-065-105 01245787 Row-3 7-5-112-005 01245787 Row-4 8-5-012-005 01245787 Row-5 8-6-030-125 01245787 Now, here is the way I'd like to have the spreadsheet columns look with the Index_No (can be either Numeric or Text - depending on your recommendations). The sort order is based on 1st, the index number, then 2nd the Tract_ID: Row-1 Index_No Tract_ID Parcel_ID Row-2 1 7-5-065-105 01245787 Row-3 2 7-5-112-005 0126A560 Row-4 3 8-5-012-005 01005147 Row-5 4 8-6-030-125 01000541 Then, let's say the user wants to enter a new value like say, 7-5-105-021. That value would need to go between Row-1 and Row-2, which, if they just inserted the value in the row of their choice, would screw up the indexing. What I need is a way to ALWAYS create an index (automatically), no matter where they decide to put the value in the spreadsheet, AND it would update all of the other Indexes as well (very important requirement). So the end result would be this: Row-1 Index_No Tract_ID Parcel_ID Row-2 1 7-5-065-105 01245787 Row-3 2 7-5-105-021 00547419 Row-4 3 7-5-112-005 5126A560 Row-5 4 8-5-012-005 00005147 Row-6 5 8-6-030-125 00001541 If you need more information, please let me know. TIA for your replies. Phil. BTW, if you are noticing that this was posted in another MS NG, you'd be correct, but I have decided to post here as well, as one of the respondents commented that this might be better done with VBA. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Tom,
Your solution worked perfectly. Thank you. However, after running it, I realized that the routine will not reveal the newest records (when I get the spreadsheet back from the field people), and therefore, I need to modify the requirement parameters. What I need instead, is after the user enters a new row for the record, the routine finds the last index number, then increment from the last number +1, and place it in the blank Index_No cell next to the new record. So, it would be like this: Index_No r2 1 .... r526 525 And if the user wanted to insert a new record at say, row 500, then the new Index_No for that record would be 526. That way, when I get the spreadsheet back, I can see instantly (after doing a sort) where all the new records are. Also, is there a way to incorporate the macro so that it will: a) do the insert row as well using maybe the "Selection.EntireRow.Insert" command, AND b) place the cursor in the 1st column to the right of the new index number? What do you think? Thanks again. Phil. "Tom Ogilvy" wrote: Sub BBB() Dim rng As Range With ActiveSheet Set rng = .Range(.Cells(2, 2), .Cells(2, 2).End(xlDown)) End With Set rng = rng.Offset(0, -1) rng(1) = 1 rng(2) = 2 rng(1).Resize(2, 1).AutoFill rng End Sub Just run it after you have inserted your new row and have completed entering your new data. -- Regards, Tom Ogilvy "Phil" wrote in message ... Hello, I am working with a group of individuals that will be passing around an excel spreadsheet to one another, and wanted to come up with a way to have the 1st column act as an index, with the key component requiring that the index column would automatically re-number itself, if someone entered a new row. A typical value in the first column looks like this: 8-5-012-005 Which in our case means that there are 4 series of number sets, separated by dashes. So the first set is 8, the second 5, the third 012, and the fourth 005. The available range for the sets are 7 or 8 for the first, 5 through 9 for the second, and 0 through 130, and 0 through 200, respectively. So the user can pick any of these ranges for when they decide to create a new record (row). Here is the way the spreadsheet columns currently look (always sorted by Tract_ID): Row-1 Tract_ID Parcel_ID Row-2 7-5-065-105 01245787 Row-3 7-5-112-005 01245787 Row-4 8-5-012-005 01245787 Row-5 8-6-030-125 01245787 Now, here is the way I'd like to have the spreadsheet columns look with the Index_No (can be either Numeric or Text - depending on your recommendations). The sort order is based on 1st, the index number, then 2nd the Tract_ID: Row-1 Index_No Tract_ID Parcel_ID Row-2 1 7-5-065-105 01245787 Row-3 2 7-5-112-005 0126A560 Row-4 3 8-5-012-005 01005147 Row-5 4 8-6-030-125 01000541 Then, let's say the user wants to enter a new value like say, 7-5-105-021. That value would need to go between Row-1 and Row-2, which, if they just inserted the value in the row of their choice, would screw up the indexing. What I need is a way to ALWAYS create an index (automatically), no matter where they decide to put the value in the spreadsheet, AND it would update all of the other Indexes as well (very important requirement). So the end result would be this: Row-1 Index_No Tract_ID Parcel_ID Row-2 1 7-5-065-105 01245787 Row-3 2 7-5-105-021 00547419 Row-4 3 7-5-112-005 5126A560 Row-5 4 8-5-012-005 00005147 Row-6 5 8-6-030-125 00001541 If you need more information, please let me know. TIA for your replies. Phil. BTW, if you are noticing that this was posted in another MS NG, you'd be correct, but I have decided to post here as well, as one of the respondents commented that this might be better done with VBA. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
how can i automatically generate work order numbers from work orde | Excel Discussion (Misc queries) | |||
HOW TO AUTOMATICALLY GENERATE NUMBERS IN EXCEL | Excel Discussion (Misc queries) | |||
automatically generate unique serial numbers for invoices | Excel Worksheet Functions | |||
Auto generate numbers in decending order in a column | New Users to Excel | |||
How to automatically number an index column | Excel Worksheet Functions |