![]() |
Merged cells numbering
I have a database, where in the first column some cells are merged (by
2, 3 or more) and some are not. I want to number them in order that every single or "group-of-merged-cells" cell will have just one number. Excel says that autonumbering could be applied only to cells with the same size. For example, first cell is single, 2nd + 3rd are merged, 4th is single and 5th+6th+7th are merged. This way about 10000 rows in first column. How to number them in order? I have a VBA script to number them, but (in the example above) first has number one, second has number two, BUT third (it is row number 4!) has number 4 = they are numbered from the first cell of the merged group. It is wrong, on the 4th row it has to be a "3". Huh, apologise my poor english, I hope the problem is set clear ;o) Thank you for answer, Imagino |
Merged cells numbering
Sub numberCells()
Dim i As Long, j As Long i = 1 j = 1 Do If Cells(i, "B").MergeArea.Rows.Count 1 Then Cells(i, "B").Value = j i = i + Cells(i, "B").MergeArea.Rows.Count Else Cells(i, "B").Value = j i = i + 1 End If j = j + 1 Loop Until j 20 End Sub might be a possibility. As written it goes down column B. Change to reflect your column. Adjust i to reflect the row you want to start in. and change 20 to indicate when to stop numbering. -- Regards, Tom Ogilvy "Imagino" wrote in message om... I have a database, where in the first column some cells are merged (by 2, 3 or more) and some are not. I want to number them in order that every single or "group-of-merged-cells" cell will have just one number. Excel says that autonumbering could be applied only to cells with the same size. For example, first cell is single, 2nd + 3rd are merged, 4th is single and 5th+6th+7th are merged. This way about 10000 rows in first column. How to number them in order? I have a VBA script to number them, but (in the example above) first has number one, second has number two, BUT third (it is row number 4!) has number 4 = they are numbered from the first cell of the merged group. It is wrong, on the 4th row it has to be a "3". Huh, apologise my poor english, I hope the problem is set clear ;o) Thank you for answer, Imagino |
All times are GMT +1. The time now is 05:47 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com