Description:
You can Merge UnMerge Cell Range in Excel VBA, it is required if you want to make bigger cells, instead of existing cell to fit your data and needs.
Merge UnMerge Range in Excel VBA – Solution:
We can use Merge and UnMerge methods of a Range to Merge UnMerge Cell Range in Excel VBA.
Merge UnMerge Cell Range in Excel VBA – Example:
Following is the example to show you how to merge or UnMerge the cells in excel using VBA.
Code to merge Cells
Sub sbMergeRange() Range("A1:B3").Merge End Sub
Code to unmerge Cells
Sub sbUnMergeRange() Range("A1:B3").UnMerge End Sub
Instructions:
- Open an excel workbook
- Press Alt+F11 to open VBA Editor
- Insert a Module for Insert Menu
- Copy the above code and Paste in the code window
- Save the file as macro enabled workbook
- Press F5 to execute it
A Powerful & Multi-purpose Templates for project management. Now seamlessly manage your projects, tasks, meetings, presentations, teams, customers, stakeholders and time. This page describes all the amazing new features and options that come with our premium templates.
LIMITED TIME OFFER
Advanced Project Planning Templates
Excel Templates
120+ Project Management Templates Pack
Excel | PowerPoint | Word
ULTIMATE RESOURCE MANAGEMENT TEMPLATE
Excel Template
50+ Essential Project Management Templates
Excel | PowerPoint | Word
Project Portfolio Management Templates
Excel | PowerPoint Templates
50+ Excel Project Management Templates
Excel Templates
Share This Story, Choose Your Platform!
4 Comments
Leave A Comment
You must be logged in to post a comment.
but i want to merge cells in two for loops based on i and j.
for example,
I want to merge (i,j) and (i,j+1)
how is syntax here?
You can dynamically reference cells using cells inside the range.
My code usually looks like this:
Range(Cells(row #, column #), Cells(Last row, Last column)
Hope that helps.
Cass, Thanks for the reply. Can you go one step further and show how to initiate a right, left or center justification of the merge.
Thanks,
Sam
hi,
i want to merge a particular rowcells with referring the merged cells in any column of that particular row kindly just the coding for that
Regards,
Janu