Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy paste non merged to merged cells [email protected] Excel Worksheet Functions 1 February 5th 09 05:25 PM
Auto Numbering a merged Cells Excel 2003 Ommm Excel Discussion (Misc queries) 8 February 5th 09 02:40 AM
Autofit Merged cell Code is changing the format of my merged cells JB Excel Discussion (Misc queries) 0 August 20th 07 02:12 PM
how do i link merged cells to a merged cell in another worksheet. ibbm Excel Worksheet Functions 3 April 27th 06 11:40 PM
Sorting merged cellsHow do I sort merged cells not identically siz Laval Excel Worksheet Functions 1 November 3rd 04 09:40 PM


All times are GMT +1. The time now is 05:28 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"