• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

a macro for merge cells

hoomantt

Member
Hi every professionals;
i want a macro with a short key (such as Ctrl+Q) to merge selected cells with mouse drag .
my cells are in a column(e.g column A) and there is a data in first cell that i want to merge.
for example i want to merge cells with short key (Ctrl+Q) A5:A12 and just data only is in first cell (here in cell A5)
 
Hi Tehrani ,

Can you clarify what is the meaning of "...to merge selected cells with mouse drag." ?

What I have understood from your post is that :

1. You will select the range of cells you wish to merge e.g. A5:A12

2. You will press CTRL Q

The outcome should be that the selected cells range will be merged into one cell , and the data which was in the top-most cell of the selection will be displayed in the merged range.

Narayan
 
Hi, hoomantt!

Just as it come out of the oven of the built-in macro recorder:
Code:
Option Explicit

Sub Macro1()
'
' Macro1 Macro
'

'
    With Selection
        .HorizontalAlignment = xlCenter
        .VerticalAlignment = xlBottom
        .WrapText = False
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
    Selection.Merge
End Sub

Put that piece of code any user module, then from Excel go to Programmer tab, Code group, Macro icon, and from the displayed window select the Macro1 macro, click on Options button, enter "Q" (unquoted), Accept, close the window, and that's all.

Just advise if any issue.

Regards!
 
Back
Top