Hi David,
Issue 1:
To be honest, I miss the point of using a macro
altogether, whether mine or yours. If you use the <Ctrl
button to individually select separate blocks of cells
then Excel treats these as separate areas whether
contiguous or not. You can separately select single
column vertical cell blocks, single row horizontal cell
blocks, multi-column (or multi-row) cell blocks. The
selection process thus identifies the merge ranges. You
can then manually merge these multiple cell blocks as
separate units (Format|Cells|Alignment tab|Merge cells
check box). For instance, if you want to merge the
following ranges as separage blocks then select them
separately using the <Ctrl key. Then manually merge them
as a single action:
A1:A5 (single column vertical merge)
B1:B5 (single column vertical merge)
D1:F4 (combined merge)
E4:H4 (single row horizontal merge)
This gives you more control than a hard coded macro that
only does single column (or single row) merges and you
don't have to keep a macro on hand.
Issue 2:
Is listing my email address in my post what you meant by
using my name? I naively used my real email address on
DevDex and got spammed to death to the point that my email
is now nearly useless.
Regards,
Greg
-----Original Message-----
To merge separate areas vertically the following
might be more suitable. Only merge within an area.
http://www.mvps.org/dmcritchie/excel/merge.htm
i.e. A1:B4, F1:B4, A10:B14, F10:B14
Sub MergeCxC()
'-- Merge cells in multiple selected areas Column by
Column ---
' limited to the usedrange (Ctrl+End)
' D.McRitchie, 2002-05-31 in merge.htm
Dim rng As Range
Dim rw As Range, ix As Long
Set rng = Intersect(Selection, ActiveSheet.UsedRange)
If rng Is Nothing Then
MsgBox "nothing in usedrange to be merged"
GoTo done
End If
Dim i As Long, j As Long
For i = 1 To Selection.Areas.Count
For j = 1 To Selection.Areas(i).Columns.Count
Application.DisplayAlerts = False
Selection.Areas(i).columnss(j).MergeCells = True
Application.DisplayAlerts = True
Next
Next
done:
End Sub
I think you would get a lot more out of newsgroups if you
used your name, particularly in technical and business
newsgroups.
---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed
Nov. 2001]
My Excel Pages:
http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page:
http://www.mvps.org/dmcritchie/excel/search.htm
"Greg Wilson" wrote
l...
Is this what you want?
Sub MergeVert()
Dim Col As Range, MergeRng As Range
For Each Col In Selection.Columns
Set MergeRng = Application.Intersect(Col, Selection)
MergeRng.MergeCells = True
Next
End Sub
"the second" wrote in
I would like to ask a favor to somebody here to write
for
me a macro for merging vertically all the cells in a
selection.
.