#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Merge Cells

I wish to merge all empty cells in a selection with the first non
empty cell above retaining that value e.g.

Smith
<empty
<empty
Jones
Bloggs
<empty

Smith)
)Merged
)
Jones
Bloggs)
)Merged

and so on...

any ideas?

Pete
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Merge Cells

Sub MergeCells()
Dim rng As Range, cell As Range, ar As Range
Set rng = Selection.SpecialCells(xlBlanks)
For Each ar In rng.Areas
Set cell = ar.Offset(-1, 0).Resize(ar.Rows.Count + 1)
cell.Merge
Next
End Sub


Special cells is restricted to the usedrange, so make sure the cells at the
bottom in the selection are included in the usedrange.

--
Regards,
Tom Ogilvy



"Pete" wrote in message
m...
I wish to merge all empty cells in a selection with the first non
empty cell above retaining that value e.g.

Smith
<empty
<empty
Jones
Bloggs
<empty

Smith)
)Merged
)
Jones
Bloggs)
)Merged

and so on...

any ideas?

Pete



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
Automatically merge mulitiple cells to one cells Edward Wang Excel Worksheet Functions 5 September 15th 09 07:56 PM
How to merge two cells? Tippo22 Excel Discussion (Misc queries) 3 December 11th 08 10:26 AM
how do I merge cells into one then delete the original cells? LLR Excel Worksheet Functions 2 March 7th 08 10:59 PM
Merge Cells trunzop Excel Discussion (Misc queries) 2 February 23rd 07 05:11 PM
How do I merge cells in Excel, like just 2 cells to make one big . chattacat Excel Discussion (Misc queries) 2 January 19th 05 04:25 PM


All times are GMT +1. The time now is 09:24 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"