Record a Macro to Merge/DeMerge cells in Excel

In our earlier posts we discussed how to record a Macro and we discussed one example to record a macro to AutoFit. Lets take one more example to create a Macro to Merge and De-Merge the selected cells quickly, which is otherwise a long procedure.

Steps to create a Macro for Merge

1. Start Macro Recorder and name it as "MergeCells"
2. Select the cells you want to merge. You can also select two blank cells.
3. Click on "Merge and Centre" button on the Formatting toolbar.
4. Stop the Macro Recorder.

Press ALT + F11 and open the Visual Basic Editor. You will see that the following code is generated.

Sub MergeCells()
'
' MergeCells Macro
' Macro recorded 3/7/2008 by Ravi Sagar
'
 
'
    With Selection
        .HorizontalAlignment = xlCenter
        .VerticalAlignment = xlBottom
        .WrapText = False
        .Orientation = 0
        .AddIndent = False
        .ShrinkToFit = False
        .MergeCells = False
    End With
    Selection.Merge
End Sub

Do not worry much about all the lines written here. The only thing that should be your concern is the line Selection.Merge, it tells Excel to Merge the selected cells.

Steps to create a Macro for DeMerge

1. Start Macro Recorder and name it as "DeMergeCells"
2. Select the cell you want to DeMerge. You can also select Merged Cell from the above operation.
3. Right Click on the selected cells > Format Cells > Alignment Tab > Under Text Control, uncheck the "Merge Cells" check box.
4. Stop the Macro Recorder.

Press ALT + F11 and open the Visual Basic Editor. You will see that the following code is generated.

Sub DeMergeCells()
'
' DeMergeCells Macro
' Macro recorded 3/7/2008 by Ravi Sagar
'
 
'
    With Selection
        .HorizontalAlignment = xlCenter
        .VerticalAlignment = xlBottom
        .WrapText = False
        .Orientation = 0
        .AddIndent = False
        .ShrinkToFit = False
        .MergeCells = False
    End With
End Sub

In this code the statement .MergeCells = False unmerges the selected cell.

I hope now you will get good idea about recording macros in the Excel sheets. I our future post we will discuss the recording of macros in OpenOffice.

watches

es it’s Rolex Day Date Watches not just a grade 1 replica watches charming splashy watch, quality Bvlgari watches but and an discount Hublot watches deeply suitable particular Imitation Rolex watches severely. The plan Swiss Army fake watches is what firstly best replica watch sites attracts your weight imitation Hublot watches at the major replica designer watches Seiko Ananta roll high quality fake watches in rush Chronograph buy Louis Vuitton watches head for corporeal top quality replica watches is a powerful, AAA replica Cartier watches male analog watch fake Omega De Ville watches that approaches a knock off Tag Heuer watches quite sightly temper imitation Tag Heuer watches useful to its Omega Constellation Watches cheap Cartier watches high quality replica watches replica saleexperi

le bracelets Breguet

le bracelets Breguet Classique Mens Watch 5930BB.12.986 and a lot more designer replica watches item are sold by Istituto Idrografico R. Marina replica these online stores that fit your clothes and your style. It Cheap Fake Watches is pertinent to choose ROLEX-M173 an online store carefully high quality fake watches as you may be disappointed on not receiving the item cz jewelry even after payment. Check The Vintage Ruby Red Cubic Zirconia CZ Ring online sales the reputation of the fake Celebrity Inspired Sterling Silver Triple Diamond CZ Bangle Set company selling imitation jewelry and you can also Balenciaga Large Giant Part Time Bag in Coffee bags go through the customer GUCCI LARGE INDY CREAM W/CREST - GUINDYCREALM replica bags reviews and this will replica bags help you to find the best store to satisfy your needs. replica handbags With imitation jewelry, you Chloe 220 Chocolate CL220-06 can do a lot top replica bags of experimentation. You can follow the recent trends and replica watches even try some new replica watches metals that are fancy replica watches and are in contrast to suit your special outfit for yo

Christian Louboutin shoes

Above these goods really good, so beautiful jewelry!Christian Louboutin shoesReally to be commended!

macro records your mouse

macro records your mouse clicks and keystrokes while you work and lets you play them back later. You can use a macro to record the sequence of commands you use to perform a certain task.When you run the macro, it plays those exact commands back in the same order, causing Excel to behave just as if you had entered the commands yourself.

Money gayweather loves

Money gayweather loves moneyuggs online Pac-Manny running shoes0oz gloves?
ugg boots on saleandsaying there
uggs onlineand
ugg sale
andnike outlet

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
2 + 5 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.