PDA

View Full Version : Solved: How to merge Empty cells in a selection



sankartalam
08-10-2008, 06:27 AM
Hi all,
could anyone help me in merging empty cell in a selection.

My idea is as follows

I have a range of cells selection i.e., A1 to F10. In this selection I have some empty cells f1,f2,f3 and E6,E7,F6,F7... etc. In my selection i want to merge empty cells. The empty cells may change. For better understanding the scenerio I am sending an attachment.
Either the selection or the empty cells of the selection may change.Even though we should have to search for the empty cells for any selection and has to merge those empty cells in the selection.
Could anyone help me to complete my task.


Thanks InAdvance
Sankar

mdmackillop
08-10-2008, 12:27 PM
Sub MergeAreas()
Dim tmp, i As Long
tmp = Selection.SpecialCells(xlCellTypeBlanks).Address
tmp = Split(tmp, ",")
For i = 0 To UBound(tmp)
Range(tmp(i)).MergeCells = True
'Demonstrate result
Range(tmp(i)).Interior.ColorIndex = 6 + i
Next
End Sub

sankartalam
08-11-2008, 12:43 AM
Thanks alot mdmackillop.