-
Solved: How to merge Empty cells in a selection
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
-
[vba]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
[/vba]
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules