+ Reply to Thread
Results 1 to 2 of 2

Merged cells numbering

  1. #1
    Imagino
    Guest

    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

  2. #2
    Tom Ogilvy
    Guest

    Re: 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" <[email protected]> wrote in message
    news:[email protected]...
    > 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




+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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