Power BI is a data analytics & visualization software. It is one of the most popular and powerful way to work with complex business data. In this page, you will find a comprehensive guide to start your Power BI journey.
Getting Started with Power BI – Table of contents
- What is Power BI?
- Who should use Power BI?
- How to get it?
- Building your first report with Power BI – Tutorial
- Understanding Power BI Desktop UI
- Loading the sample data
- Adding visuals
- Changing calculations
- Understanding interactions
- Putting it all together – Making a sample report
- Saving & Publishing your report
- Updating / Refreshing the report
- When to use each of the Power BI visualizations?
- Video tutorial – Introduction to Power BI
- Downloads – Sample data, completed report
- Glossary of terms
- Power Query
- Power Pivot
- DAX
- M Language
- Data model
- Relationships
- Measures
- Interactions
- Filters, Slicers
- Refresh
- Resources to learn Power BI
- Websites
- Books
- Video Channels
- Online Courses
- Latest on Power BI, PQ and PP from Chandoo
- Closing Remarks on Power BI
What is Power BI?
Power BI is a software to create & publish reports and data stories from your data-sets. You can make highly interactive, engaging and powerful reports, dashboards or visuals with Power BI. You can connect to any data (Excel files, SQL databases, BI warehouses, Cloud data, APIs, web pages and more), mashup the data, link one table with others, create clickable visualizations and then share them with your audience securely thru Power BI.




Who should use Power BI?
If your job / business or life depends on data, then you can use Power BI. There are two kinds of users for Power BI – Creators & Consumers.
Creators are people who make stuff in Power BI.
Consumers are people who read / view things built in Power BI.
Power BI Creators are typically:
- Reporting professionals
- Analysts
- BI Developers
- Visualization Specialists
- Story tellers / Presenters
On the other-hand, almost anyone can be a Power BI consumer.
How is Power BI different from Excel?
So what, even Excel can create interactive reports. But there are several crucial differences between Power BI and Excel.
- Power BI allows rich, immersive and interactive experiences out-of-box. You can click on a bar in bar chart & other visuals respond to the event and highlight or filter relevant data. You can show graphs & visuals that are very tricky (or impossible) to reproduce in Excel like maps, pictures and custom visuals.
- Power BI works with large data sets There is no artificial limit of 1mn rows in Power BI. You can hookup to a business data set and analyze any volume of data. The limit depends on what your computer (or Power BI server) can process.
- Share and read reports easily You can create reports in Power BI and share them in formats that are universal (i.e. browser pages or apps). This means, your boss need not have Excel or Power BI installed to enjoy the beautiful reports you create.
- Power BI is for story telling while Excel is for almost anything. We can use Excel to simulate pendulum motion, calculate Venus orbit, model a start-up business plan or many other things. Power BI is mainly for data analysis & story telling. If you try to replicate a large, intricate financial model or optimization problem with Power BI, you will either fail or suffer miserably. On the other-hand, if you use Power BI for making reports, running cool analysis algorithms (clustering, outlier detection, geo-spatial patterns etc.) you will wow your colleagues and bosses.
How to get Power BI Software?
Power BI Desktop software is free to download. Just head to Microsoft Power BI website and download the version for your computer.
Things to keep in mind when downloading and installing Power BI:
- Power BI is always changing. Almost every month, Microsoft releases a new version of the software. One simple way to stay on top is to install Power BI thru Microsoft Store (on Windows 10). This way, your computer will automatically update the software whenever there is a new version.
- You do not need PowerBI.com account to use Power BI Desktop. While Power BI may prompt you to login, you can use the software without registering for the online account. However, you can sign up for free PowerBI.com account.
- Login to publish & share your work. Although you can use PowerBI without logging in, you must log-in if you want to publish or share your reports with others.
Building your first report in Power BI - Tutorial
Okay, so you have downloaded Power BI and eager to play with it. Here is a step by step tutorial to help you.
We will use sample employee data for this process. Click on below button to download it.
#1 - Understanding Power BI Desktop UI
Open Power BI Desktop application. After you exit the welcome splash screen, you will see the blank Power BI application. Let’s understand this screen. Here is an illustration explaining 11 important features / buttons in Power BI Desktop.
11 Important features of Power BI Desktop UI
- Ribbon. Find most important and regular stuff in Home ribbon. Navigate to other ribbons for specific functionality.
- Get Data. Use this button to get data from almost anywhere – Excel files, websites, databases, APIs etc.
- View selection, by default you will be on Report view. Change to data or model view to see behind scenes.
- Fields Access the tables and fields (columns) of your data here. Use them in visuals (5) or filters (7) etc.
- Visualizations add charts, tables, maps, filters etc to the report from here.
- Visual Fields, Format and analytics use this area to set up and customize your visualizations (charts etc.) Note the paint-roller, use it to edit colors, fonts, settings etc.
- Filters – set up chart, page, report level filters here. Anything you restrict will be removed from all the linked items.
- Canvas this is where you construct your reports.
- Save your Power BI reports by pressing CTRL+S or clicking on this button. They will be saved as PBIX files.
- Publish the reports with this. You can publish them to online (either free PowerBI.com account or paid plans) so that others can access your reports.
- Add more pages to your report using the + button.
#2 - Load data into Power BI
#3 - Adding Visuals
Working in Power BI feels like playing with your data. This is because of the drag-and-drop nature of report building process. To add a visual,
- Click on the type of visual you want.
- A blank visual will be added to available empty space on your report canvas.
- Select fields from your data and add them to relevant places.
- Axis
- Values
- optionally legend
See this demo to understand the process.
How Power BI visualizations are different...
- Power BI visualizations are always interactive
- They are sorted by default (for ex: descending order for column charts)
- Value field will be the number of chart. You can change the calculation to SUM / COUNT / AVERAGE etc.
- You can even use DAX Measures in the value area of charts
- All visualizations support extra tool-tips (both simple and report-page type tooltips)
- Use Legend field (where available) to see 2nd level detail.
- When you add multiple fields to axis, Power BI adds drill-down buttons to see chart at various levels
#4 - Changing Calculations for the Visuals
You can use two methods to change the calculations for the charts.
- Use default options for calculations – SUM / COUNT / AVERAGE etc.
- Write your own calculations with Power Pivot measures
To change the calculation of a chart with default options, follow below steps.
- Select the power BI visual
- Go to Value field.
- Click on the little down arrow symbol.
- Select the type of calculation you want.
- Done.
Here is a quick demo of changing chart calculations in Power BI. It shows how to change the chart from SUM of salary to AVERAGE of salary.
#5 - Understanding Power BI Interactions
Power BI visuals are interactive. This means, if you have more than one chart on a report page, when you click on a particular item on a chart, all other charts respond to the selection and change.
This is quite different from normal Excel charts, but once you get used to it, you will see the true power of Power BI visualizations.
Here is a quick demonstration of Power BI visual interactions.
Power BI interactions - FAQs
Here are some of the common questions you may have about Power BI report interactions.
Are all visuals interactive?
By default, all visualizations in Power BI report are interactive. The only exception is card visuals. They are not interactive. So if you click on them, nothing happens to other charts.
How to unselect ?
Simple, click or touch the selected item again. The interaction will be gone.
How to disable or change interactions?
Select any visual, go to Format ribbon. Now click on “Edit interactions” button. This will show interaction buttons on top of all your visuals. Click on do not interact button (looks like no entry sign 🚫).
You need to do this for each visual.
I want to filter instead of highlight on interaction…
You can use the “Edit interactions” button to change the style of interaction. There are three possible interactions (as depicted to the right). 
- Filter
- Highlight
- No interaction (no entry sign – 🚫)
#6 - Putting it all together - Making a sample report in Power BI
Now that you have some understanding of Power BI, let’s create our first Power BI report. The focus of this report will be,
- For a specific manager
- Show staff distribution by department
- Gender break-down
- All of their staff by salary and rating
This is a fairly simple report, but it does demonstrate the power, elegance and ease of working with Power BI.
Here is the final output we will create.
Step by step instructions for our first Power BI report:
- Load the employee data into Power BI. (here is the file).
- Add a column chart.
- Department on axis
- Name (count of name) in values area
- Add pie chart
- Gender as Legend
- Name (count of name) in values area
- Add a table with name, age, rating and salary fields
- Add a slicer with manager as field
Our report is almost ready.
Adding conditional formatting
Background colors on rating field:
Select the table. Click on down arrow symbol next to Rating and apply conditional formatting > Background color. Set up a color scale as shown below.

Data bar for Salary:
Click on conditional formatting for salary, set up data bars as shown below.

Adding title for the report
From Home ribbon in Power BI, click on Text box and type your report title in that. Format the text and position it on the top.
That is all, your first Power BI report is ready.
Play with slicer or charts to see powerful insights from this report.
#7 - Saving & Publishing your Report
To save your Power BI report, press CTRL+S. This will save a copy of your report on your computer. Power BI files use the .PBIX as extension.
How to share / publish your reports?
You can publish your reports in various methods.
- Email or share the file: this is the simplest method. Just email or share the file with your audience. They will need Power BI Desktop to view the reports though. Also, they will need to access the source data sets to be able to refresh or update the reports.
- Publish to Power BI online: This is the recommended way to sharing your reports. But you do need PowerBI account (either paid or free) to be able to publish the files to online workspace. Once you publish your reports to the workspace, you can invite others to view them or pin parts of it to a dashboard etc.
- Share to Mobile / Tablet via Power BI app: Once you publish the reports to Power BI workspace, others can view the reports on web or on mobile / tablet apps by accessing the workspace.
#8 - Updating & Refreshing your Report
With Power BI, you create once, use forever. As your business data changes, all you need to do is, refresh the report. This will automatically fetch any new data from your source, update all calculations and visuals. If you publish the report again, this will replace the online version with new one so your colleagues or clients can access updated reports easily.
What if your data format changes?
For example, if you add new columns or rename things, then you may need to rebuild some visuals or calculations. You will notice any broken items upon refresh and you can easily fix them.
When to use each of the Power BI visualizations?
As of November 2019, Power BI has got 34 default visualizations. You can also install any of the 100s of custom visualizations from Power BI marketplace. All of this can be overwhelming. So I made this handy illustration and check-list to help you decide the right visualization for any situation.
Picking right visualization for your situations...
Compare one with another
- 2 items to compare: Use two cards or KPI visualization.
- Up to 12 items: use column or bar charts
- More than 12 items: Use tables with conditional formatting. Try column / bar charts with Top N filter if you want to see top few items.
Trends, changes over time
Use line charts or area charts with time on x axis with oldest time to left.
If you have just two points in time and want to compare the changes, consider the waterfall chart.
You can also toy with ribbon chart to see if that provides any valuable insights.
Composition, how things add-up?
Use 100% stacked bar / column charts, area charts.
When you have few values to see the composition, use pie chart or donut chart.
As Power BI is interactive, you can getaway with having too many (but definitely not 100s) of slices in your pie / donut charts.
When you have lots of values with few clear outliers, try the tree-map visualization.
Spacial distribution
Use Maps for geographical distribution of data.
- Bubble map: when you have data about specific locations
- Filled map: when you have data for regions
- ESRI maps: for maps with additional reference layers (say population, crime rate, GDP etc.)
For distribution by floor / store shelves or something else, use shape maps.
Distribution
For one-dimensional distribution, use line or area charts
For two-dimensions, use scatter plot
More than two-dimensions, you may want to avoid the visualizations altogether as they can be quite hard to explore. If you must, try a table.
Outliers, what is different?
Use column, bar or table charts with conditional formatting to bring out the differences.
You can also try the key influencer visualization to let Power BI analyze your data and tell you what is the most significant item impacting outputs.
Simple numbers, messages and indicators
Use card visualizations or KPI visualization.
Video Tutorial - Getting Started with Power BI
Here is a complete tutorial on how to start from zero and create a report with Power BI. Please watch it to learn what Power BI is, how various components of the technology (Power Query, Power Pivot and Visualizations) relate to each other and how to work with the software for the first time.
Download the Getting Started Files
Power BI - Glossary
Power BI is a new and rapidly evolving technology. There are a lot of technical terms you will hear as you start using Power BI more. Here is my list of top 10 Power BI glossary.
Power Query
Power Query is the data processing engine for Power BI. Whenever you connect to a data source using “Get Data” button, you are using Power Query. This engine runs in the background to,
- connect to data sources
- gather data
- change / pre-process data based on rules
- combine multiple datasets to form one table (joins, appends)
- publish finished datasets to Power BI for analytics and visualization.
You can use Power Query in Power BI or in Excel too.
Here is introduction to Power Query.
Power Pivot
Power Pivot is a calculation engine for Power BI. You can use Power Pivot to model complex data, set up relationships between tables, calculate things to be show in value field area of tables or visuals.
Think of Power Pivot as a calculation layer between your data and outputs. You can tell Power Pivot how you want your calculations done thru a language called as DAX and Power Pivot can give the answers. It is an extremely fast & scalable software.
We can use Power Pivot in either Excel or Power BI.
Here are some links about Power Pivot. They explain it from Excel perspective, but the idea is same.
DAX
DAX stands for Data Analysis eXpressions. This is a language for calculating things with Power Pivot.
DAX expressions or formulas look almost like Excel formulas.
Example DAX formula:
Total Salary: =SUM(Table1[Salary])
Sums up Salary column in the Table1 and presents it wherever you use this [Total Salary] measure.
M Language
Note: the link to Gil’s book uses my Amazon affiliate code.
Relationships
You can link two tables based on a column. This is called relationship.
For example,
Say have two tables – Sales & Customers.
You can link Sales table and customer table based on Customer ID. We then say Sales & Customer tables are related.
It means, both columns have the same meaning.
There are two kinds of relationships.
- One to many relationships: a value in one table is linked to one or more values in another table. Example: Customers to Sales relationship. Each customer appears once in Customers table but can have many matching transactions in Sales table.
- Many to many relationships: Each value in one table can be linked to one more more values in other table and vice-a-versa. For example: People and Projects. Each person can be part of any number of projects. Each project can have one or more persons.
Measures
Measure or calculations are what gets displayed in visuals / tables / cards.
The Count of Name, Average Salary things we used earlier are measures.
There are three kinds of measures in Power BI.
- Implicit measures: These are automatically created when you drop a filed in the “Value” area of a chart / visual. Example: Count of Name.
- Explicit measures: These are the ones you create by using DAX language. Example: =SUM(Table1[Salary])
- Quick measures: These are same as ‘explicit measures’ but instead of typing the DAX formula, you use Power BI quick measure feature to make them.
You can create measures by right clicking on a table (area 4 in the Power BI Desktop UI) or clicking on the “New Measure” button on the ribbon.
Data model
Imaging a big black box with all your tables and any relationships between them along with the measures you have defined. This black box is your data model.
Other common names for data model are Cube, tabular model or simply model.

Interactions
Interactions refer to the clicks and selections you make on the report to see data relevant for selection.
Here is a quick demo of Power BI interactions.

Filters & Slicers
While interactions allow you to peak at data for a point, Slicers & Filters allow you to restrict an entire report or visual(s) to use only some part of your data.
Power BI offers various levels of filtering.
- Slicers: These are on-page filters. By default they interact with every visual on the page and update them whenever you change something. For example: Manager slicer in our Power BI report from above.
- Visual level filter: This is a filter set on a specific visual. It will not impact other visuals on the page.
- Page level filter: This will act on all the visuals on a page and restricts the data that is sent to them for calculation.
- Report level filter: This will impact all pages in a Power BI report.
Only slicers can be added to a report page. Other filters are set in “Filter Pane”.
Refresh
Refresh refers to the concept of updating all the data, calculations and visuals based on source data changes. You can manually trigger refresh by clicking on the “Refresh” button in Power BI Desktop Home ribbon.
You can also schedule refresh for online published reports so that every day (or whatever frequency you determine) Power BI online will refreshes your data and updates the published reports.
How to learn Power BI - Resources
Here are my top recommendations for learning Power BI.

Power BI Websites
My top go-to Power BI websites are,
- Microsoft Power BI blog for new updates, announcements, tips and ideas.
- Matt Allington’s blog to polish my Power Pivot skills
- Radacad by Reza Rad for amazing case studies and ideas on Power BI, Azure ML etc.
- Enterprise DNA
- Kasper on BI
- Ken Puls for Power Query to get advanced skills in PQ
- Rob Collie for Power Pivot
- Crossjoin by Chris Webb

Books on Power BI
- Mastering Power BI by Brett Powell
- Supercharge Power BI with Power Pivot by Matt Allington
- Collect, combine and Transform Data with Power Query by Gil Raviv
- Power Pivot and Power BI by Rob Collie and Avi Singh
Note: All these are Amazon affiliate links. I recommend these books because I find them immensely helpful.

Power BI Video Channels
The quickest and most fun way to learn Power BI is by watching videos. I subscribe to a handful of channels to stay on top of Power BI developments, news, tips and ideas.
- Microsoft Power BI official channel: this is the pace to go for monthly update news, community webinars and more.
- Guy in a cube: for videos on Power BI tricks, interviews and more
- Curbal: for interesting tricks, DAX and more
- My own channel: If you haven’t already subscribed to it. For all things Excel and Power BI.

Power BI Courses
Power BI is vast, technical and often confusing. If you are finding the journey too hard, consider an online course.
I recommend my own online class – Power BI Play Date. Next round of enrollments begin in late November.
Latest Power BI, PQ and PP Articles on Chandoo.org
SUMPRODUCT Vs. Power Query on Mt. KauKau
When faced with tough problems I react in one of three ways
- Come up with ingenious solutions
- See if a simpler cheat solution is possible
- Sit back and ignore
For most problems, I choose 3rd reaction. Occasionally, I rely on 2nd option and very rarely the first one.
When faced with a tricky time sheet summary problem (as outlined above), after initial lethargy I wanted to solve it.

Nest Egg Calculator using Power BI
Welcome to Power Mondays. Every Monday, learn all about Power BI, Power Query & Power Pivot in full length examples, videos or tips. In the first installment, let’s take a look at something we all can related to – Money.
We all know that Power BI is good for creating awesome visual experiences. Today let me share another fun way to use Power BI – to build a calculator. Learn how to create nest egg calculator in this Power BI parameter example tutorial.
Mutual Fund Portfolio Tracker using MS Excel
Would you like to spend next 5 minutes learning how to create an mutual fund tracker excel sheet?
Make a live, updatable mutual fund portfolio tracker for Indian markets to keep track of your investments using this example.

How to extract common values in two tables? – Power Query Tip
We, humans like to compare. Whether we are on Facebook or workbook, we want to compare. So how do you compare two tables and extract common values? Simple, use Excel Power Query. It can merge (a la join) tables and give you the common values.

Leave entitlement vs. usage analysis with Power Query
Last Friday, I asked you to analyze “sick leave entitlement vs. usage” data and answer homework questions. We got several interesting responses to that. Today, let me share a quick video highlighting how to analyze such data with Power Query.
This is part of our Power Mondays series, where every Monday you will learn something new & useful about Power BI, Power Query and Power Pivot.

Extract data from PDF to Excel – Step by Step Tutorial
Recently I had to extract data from multiple credit card statements and combine them to one Excel table. In this tutorial, let me share you simple steps to deal with PDF data and extracting it to Excel.

Top 5 HR Analytics Examples – Free Video Masterclass
I recently finished a long consulting gig with one of the government ministries in New Zealand. Guess what I was doing? HR Analytics and Reporting. In this post, I want to share my top 5 Excel tips for HR people, based on what I learned in the last 18 months.
Specifically, we will cover:
- Gathering and structuring Employee data in Excel
- How to use Power Query to collect data
- Polish / clean data in Power Query
- Bring cleaner data to Excel as refreshable table
- Answering questions about employees
- Using Excel formulas such as COUNTIFS, SUMIFS, AVERAGEIFS
- Pivot tables for data analysis
- Understanding the results quickly with conditional formatting
- Understanding pay gap
- Calculating gender pay gap
- Visualize pay gap
- Creating salary distribution charts
- Working with histogram charts in Excel 2016 / Office 365
- Making interactive charts
- Generating letters thru mail merge
- Calculating employee bonus based on bonus mapping logic
- Creating 100s of letters with a single click using Mail Merge + Word
Sounds interesting? Read on for details.
Closing Remarks on Power BI
Power BI is one of the most fun and elegant ways to work on complex data sets for analytics or reporting needs. I encourage you to learn it so that you can ahead in your work. It is both deceptively simple and inherently complex software. That means, just like Excel, almost anyone can pick up Power BI and start building things immediately. But if you know which buttons to press and what formulas to write, you can unravel a marvelous world of data analytics with Power BI.
I wish you all the best in this journey. 👍















83 Responses to “Merge Cells without Losing Data [Quick Tip]”
Yes, but with your VBA sub, you end up with a delim which should be trimmed.
Unfortunately, the company I work for is using Excel 2003 and the function will not work.
@Gerdami... I know the mistake in code. I left in on as when you concatenate such text, 99% of time you are doing it for cosmetic reasons, so an extra space wouldnt hurt + I wanted to keep the code easy to understand for our readers.
@Steve... I am not sure if that is the case. I just tested the code in Excel 2003 and it works fine. May be when you copied it, all the quotation marks ' " are replaced by wrong characters?
Chandoo, why do you provide screenshots with Excel 2007 and still continue to use Excel 2003 when Excel 2010 is out 🙂
I saw the article about you on msn. It was very inspiring. Thats how I came to know about your blog. You should also check out my blog sometime though I'm just a beginner.
Thanks.
Don't worry Chandoo, thanks for sharing this.
One more gem from Chandoo! Thanks for sharing it 🙂
Wow, I can't remember coming across this Fill>Justify tip before. Nice one. I checked Excel 2003, 2007, 2010, and Mac versions 2008, and 2011 to see if it works and it did. Amazing!
I did have to replace ‘ with ' to designate comments, and
” “ with " " in the Const declaration before my compiler would okay the code.
I did not of Fill/justify before. I noticed it could also split wrapped up text in a cell in multiple cells.
It's much different than setting horizontal text alignment to "Justify" in the format cell dialog.
Personnaly, assuming the text is in column 1, I would use =A1&" "&A2. Copy the formula down to the last row than copy/paste value the result.
Sebastien
This is a wonderful tip! Too bad it only works in Excel 2007! Keep them coming.
Don't recollect the Fill->Justify earlier and to have wasted all that time..........grrrrrrrrrrrrrr
Thanks!
Face this problem many a times.
Many of us face 'another' problem. It's actually lose and not loose. Funny how often this mistake is committed.
cheers,
PSL
Hi Chandoo
Would you consider covering the general topic of converting 2003 VBA code to 2007/10 in a future newsletter - ie what is the process of converting 2003 macros and situations like this?
Cheers
John
@PSL: Oops, I didnt realize the mistake in spelling. Fixed it now. Sadly, the url will retain an extra o.
@Godwin: Because I have all 3 versions installed on my comp!
@Sebastian: I used to the same thing (write =a1&" "&a2 and drag) a while ago. Then I ended up writing a small UDF called as CONCAT that accepts ranges as input and concatenates text in that. It is such a timesaver. Get it here: http://chandoo.org/wp/2008/05/28/how-to-add-a-range-of-cells-in-excel-concat/
@Ninad, Prakash: Thank you. I am happy you like this.
@Kamarrah: It works in Excel 2003 too.
@John: I think all macros written in 2003 work in 2007 without any changes in behavior. I may be wrong. I am not an expert in macros, but I will try to put-together an article on what you asked.
@Chandoo,
Below is your code modified to remove the loop which concatenates the output text together (note that this method does not produce a trailing delimiter in the output string like your code does)...
Sub JoinAndMerge()
' Joins all the content in selected cells
' and puts the resulting text in top most cell
' then merges all cells
Const Delimiter = " "
On Error Resume Next
With Selection
.Item(1).Value = Join(WorksheetFunction.Transpose(Selection), Delimiter)
.Item(2).Resize(Selection.Count - 1).Clear
.Merge
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlCenter
.WrapText = True
End With
End Sub
I have a question though... I left it in (because you included it), but why are you setting the WrapText property to True?
@Rick... Good modification. I tried to use Join but failed several times. It didnt occur to me that I need to transpose the data. Thanks for sharing it.
I used the WrapText option so that if the merged text becomes too large, it would wrap nicely inside the cell. I am not sure if without that option the merged content would be visible completely. What do you think?
Oops, it does work in 2003
Don't worry Steve, the problem is with the strange quotes ‘ ” “ displayed on this page.
@Chandoo,
The reason I asked why were you setting the the WrapText property to True was because of this instruction you gave above...
2. Adjust the column width so that you can fit all
contents in one cell. (basically make it wide enough)
If this instruction is followed, then there would be no need to wrap the text. By the way, we can modify this code to handle merging across a single row instead of down a column...
Sub JoinAndMerge()
Const Delimiter = " "
On Error Resume Next
With Selection
.Item(1).Value = Join(WorksheetFunction.Index(Selection.Value, 1, 0), Delimiter)
.Item(2).Resize(1, Selection.Count - 1).Clear
.Merge
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlGeneral
.WrapText = True
End With
End Sub
And, if we want to generalize the code to handle either a selection down a column or across a row automatically, then this code will do that...
Sub JoinAndMerge()
Const Delimiter = " "
On Error Resume Next
With Selection
If Selection.Rows.Count > 1 Then
.Item(1).Value = Join(WorksheetFunction.Transpose(Selection), Delimiter)
.Item(2).Resize(Selection.Count - 1).Clear
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlCenter
Else
.Item(1).Value = Join(WorksheetFunction.Index(Selection.Value, 1, 0), Delimiter)
.Item(2).Resize(1, Selection.Count - 1).Clear
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlGeneral
End If
.Merge
.WrapText = True
End With
End Sub
Note that I still retained the WrapText property setting statement (in both of these routines).
Hi Chandoo,
In your latest comment on merging cells, what are the pros and cons of using concatenate command instead of the VBA?
Also, I found a relatively simple link to merge text in cells--check this out
http://www.contextures.com/xlCombine01.html
I got to work! Yeah Chandoo thanks.
Hello Chandoo.
There is a old trick to do that.
If you have the data in a1:a5, select b1:b5 and merge the cells, copy b1:b5, select a1:a5 and Paste Special - Format then you have a1:a5 merged but the individual data in a1:a5 still remains there. If you split the cells a1:a5 you see the individual data again, even with the cells merged you can refers one of them individually.
Kind Regards. César.
Hi Chandoo,
Thank you and I need opposite action to this
If a cell contains multiople data (abc123, def456) seperated by coma/space needs to be splited into new rows below (a new row should be inserted below and the data should be populated) could you suggest...
Cheers, Chandru...
This is the macro I use.
It accounts for columns and rows and will work with normal formulas. Selection must be contiguous. (but that's a given, since we're merging the cells)
Sub MergeCells()
Dim result As String
For Each cell In Selection.Cells
If Not cell.Value = vbNullString Then
result = result & Trim(cell.Value) & " "
End If
Next
Application.CutCopyMode = False
With Selection
.Clear
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlTop
.WrapText = True
.MergeCells = True
End With
Selection.Cells(1, 1).Value = result
End Sub
Hi chandoo,
I know one formual to merge the cell in excel woth out losing data, but dnt know how to update here, Pls guide me.
And thanks a lot beca i am very curious to know abt xcel and here ia m learning so many new things.
Merge Cells without Losing Data :
I make macros for this :
Sub lastrow()
Dim lastrow
lastrow = Range("b" & Rows.Count).End(xlUp).Row + 1
Range("B" & lastrow) = Range("A6") + Range("A7")============= Range Can be multiple like range ("A5"), Range("A8") Etc.
End Sub
its very simple to merge cells you can watch it on the next tutrial:
http://www.thebestdata.com/zoom.aspx?menutype=1&auto=2189
Merge cells in Excel 2010
Here is one for you!! I'm still trying to figure out how to make it work.
Just take say 400 rows and 14 to 16 narrow columns as if you were making a bar chart, then merge every second column vertically and fill it in with color. Some of the verticals can be split two or three times vertically. The entire page will probably freeze before you get the columns complete.
Now try and work out a solution the page freeze.
Help! I've used Fill/Justify for years. Just "upgraded" to Excel 2010 for Windows. Cant find Fill Justify. Help!! Microsoft Help is worthless...
Thanks!
@Tim... It is still there. In home riboon, under Fill Option. Press ALT +hfij to access it.
Chandoo, How did you get this ? what made you increase width and select all cells and click fill > justify?? Do you have tie up with Microsoft developers 😉
[...] Merge Several Cells without Loosing Data [macros] Spread some love,It makes you awesome! Tweet [...]
Dear Chandoo,
Many Thanks for all the tips & tricks... i'm learning a lot about excel through this..
just one quick question:
how do you show the steps as a gif animation image? do you use any software? if yes, which one? even i'm curious to create some gif animations which i can show in my ppt 🙂
thanks a ton mate... & wish you & ur family a very happy diwali... 😀
regards
raghu
@Raghu
The aimated images are Animated GIF files
I believe that Chandoo uses TechSmith's, Camtasia Pro screen capture software, although there are a number of screen capture utilities that do the same thing.
What if I want to merge the cells but keep the paragraph formating so instead of one cell with "big fat cell with lots of text"
"big
fat
cell
with
lots
of
text"
Thanks
@Megan
a very simple modification to Chandoo's code will do the trick
.
Sub JoinAndMerge()Dim outputText As String
delim = Chr(10) 'This is the only change
On Error Resume Next
For Each cell In Selection
outputText = outputText & cell.Value & delim
Next cell
With Selection
.Clear
.Cells(1).Value = outputText
.Merge
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlCenter
.WrapText = True
End With
End Sub
I cannot get that to work. Is ther some kinda code for inserting a new paragraph kinda like using alt enter when your typing in a cell?
gotta use delim = vbLf
The macro you provide is great and will save me a lot of frustration, but for some reason it seems to strip all of the formatting from the text (font, font size, font color) in the newly merged cell. Is it possible to modify it so that it maintains the original formatting of the cell?
Hi folks,
Pls dont worry all about this...
just omit all the above comments..
-----------------
Just copy all the cells content whichever you need and paste it in notepad,wordpad,or msword and copy all those data from the wordfile and click inside the required cell in excel and paste it...
___________________________
thats it.... All the best
Great help! Keep Rocking (;
Hi chandoo,
I have doubt in excel VBA macro code. can u help me with it.My problem is:
I have multiple vertical cells with values in alternate (leaving 1 cell gap between 2 values)positions eg:
Date
A1: 02/Nov/2011
A2:
A3: 04/Oct/2011
A4:
A5: 12/Oct/2011
A6:
A7: 25/May/2011
21/Oct/2011
now please let me know how do I copy it to the other workbook vertically(continuously) without a gap of 1 cell inbetween 2 values.
The result is supposed to be this:
Date
A1: 02/Nov/2011
A2: 04/Oct/2011
A3: 12/Oct/2011
A4: 25/May/2011
A5: 21/Oct/2011
In sheet 1, select all the cells A1:A10,
press F5
Select Special
Choose Constants
Click ok
Press CTRL+C
Now go to Sheet 2 and Paste
Why not just a simple formula
in Date!A1 put
`=OFFSET(Sheet1!$A$1,2*ROW()-2,)`
thanks for the suggession,
but im trying it with vba. Can u please help me in this regard
hi chandoo,
this is my new problem, i solved the old one.
first i want to search for a string in an existing workbook, if it is found then i need to copy the range below it(till the data is present) into a new workbook using VBA.
Hi, I have a question related to this thread. I have a need to merge columns of data into one cell, with no data loss, but need two additional features: first is to comma seprate the contents of each of the merged cells once they are in the merged cell. second is to do this for individual rows, but whilst selecting multiplw rows - I mean only merge per row into one cell. for example, i want to be able to run the macro by selecting all rows in my worksheet, but have columns merged per row, not all rows and columns merged into one cell in teh top left of the sheet. ie I want a finished sheet of one column with the same number of rows but the columns from each row meged into the first cell of each row.
the closest i have come is with a previous post:
1. Nikki says:
December 20, 2010 at 8:36 pm
This is the macro I use.
It accounts for columns and rows and will work with normal formulas. Selection must be contiguous. (but that’s a given, since we’re merging the cells)
Sub MergeCells()
Dim result As String
For Each cell In Selection.Cells
If Not cell.Value = vbNullString Then
result = result & Trim(cell.Value) & ” ”
End If
Next
Application.CutCopyMode = False
With Selection
.Clear
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlTop
.WrapText = True
.MergeCells = True
End With
Selection.Cells(1, 1).Value = result
End Sub
this macro merges all selected columns and rows into the one cell, I want to be able to select multiple columns and rows, but only have row by row merged.
Additionally, ideally as the merge is completed i would like to insert a comma between each of the merged cells contents, once it is merged.
hope I have explained this ok?
any help is much appreciated!
Did you ever solve this?? I need to do the same thing and am lost.
@Frustratedguy
Have you tried this: http://chandoo.org/wp/2008/05/28/how-to-add-a-range-of-cells-in-excel-concat/
Also check the comments as there are lots of extensions to the basic post in the comments
If that doesn't help can you post or email me a sample file?
Hi Chandoo,
Can you tell me how to merge columns without losing the data in the format given below:
column A column b
row 1: abcd xyz
required format:
column A
row 1: abcd xyz
It would save a great amount of my time if i could get a solution to this!
Hi Jo Saave,
you can get the data in col a & col b concatenated in col c. if you need to get the merged data back in col a then you may have to copy paste.
the formula (in col A1) would be =A1&B1"
if you need the space between char in A1 & B1 then it would be
=A1&" "&B1"
hope this helps
regards
raghu
Brilliant!
The Macro works fine and good once the wrong characters are replaced with the correct quotation marks. Thanks, but when the length of the cell is high then values in the two cells will merge in single line. For this I have move to the end of each value and give alt+ enter to move the second value to the next line. Then how to resolve this?
Hi Chandoo -
Thanks for this!
Quick question: I have one column with a list of about 1000 names. Each row is a different name but some rows belong to one family. I am trying to separate each family. In order to do this, I am using your JoinAndMerge() macro. Essentially, I am merging the rows that belong to one family so that they become one cell. I will then use this and use Avery wizard (is that the easiest way to do it?) to print off the names on a avery sticker sheet.
However, when I merge the rows of names, I still need them to be in separate lines. I could do it manually with the char(10) function, but I imagine I could edit your macro a little.
What would you advise here?
Thanks a lot!
Mana
@Mana
I definitely would advise not to use Merge
I would add a new helper/ assistant column called Family
The add a formula to that to add family as appropriate
Hi All,
Any body can sujjest a VBA code for this: use logical condition in other words if column 1 with same information in different rows then join the column 3 with all rows can be joined with a comma delimiter. Here is the Example:
Input
No
Year
Text
A-1
2012
AB
A-1
2012
CD
A-1
2012
EF
B-2
2011
AB
B-2
2011
CD
B-2
2011
EF
Output should be
No
Year
Text
A-1
2012
AB, CD, EF
B-2
2011
AB, CD, EF
Hi All
There is a simple and easy way to merge celles without losing the entire data
=CONCATENATE(cell1,cell2)
thats it
hope it's helpfull
forget something that you add this formula in the next column
regards,
yasser
I was planning to write an email to following addresses:
sdkjfhds@msn.com
kjdafhk@gmail.com
jfh@gmail.com
jhdfjah@djsldf.com
in excel, then I added A1 & ", " to B1 and then I noticed here. Result is perfect.
I have never noticed that fill button before 🙂
You may have already answered this question, but I am such a newbie to excel I am not sure.
I have two columns, A & B.
Column A is the Family Number. (1k family numbers)
Column B is the Unique Name. (50k unique names)
All the Unique Names in Column B need to be merged into 1 single cell according to the Family Number in Column A. I tried using "Justify" but it wraps the names onto multiple rows because I can't make the column wide enough.
I am using excel 2007.
Thank you!
Whitney
Hi Whitney,
See this: http://chandoo.org/wp/2008/05/28/how-to-add-a-range-of-cells-in-excel-concat/
Thank you Mr. Chandoo, it appears you have the answer I need and it will save me many hours of work. Unfortunately my excel skills are so weak that I don't understand where to begin. I will try to find a class on excel programming basics so that I can learn how to implement your suggestion.
Thank you
Whitney
i keep getting a syntax error. and how do i use this?
is there any other fuction that can be used that has the same effect but there will be spce between them?
eg. cat dog and not catdog
@NaaG
See this: http://chandoo.org/wp/2008/05/28/how-to-add-a-range-of-cells-in-excel-concat/
Nice trick
Hi sir i just want a clarification from you that im preparing a travel schedule that consist of onward details and return details .. i just sorted the list based on onward date and time and now i just wanted to insert in the records in word using directory technique. everythng is ok but what the problem is im getting the list in order one below the other but i need 1 2 3 in this way not as
1
2
3
please help me in this regard
great work.. Thanx.. 🙂
We can use conconate function....to merge any cells,,,with text
This is easily possible if the data is in 2 columns. You can use this tool http://www.anotherwaytodothis.com/excel-merge/combine-join-cells.php to merge cells even with data in them.
Very Easy One Thanks,,,:)
[...] This code has been written by Chandoo, you read more ways to tackle this issue on his blog here. [...]
Is it possible to apply this macro to all rows of a 5 x 50 set of data? Sorry, I'm very inexperienced with macros.
Good.
The best solution for my need.
Rgds,
Sumit
@Sumit
Have a read of the posts here:
http://dailydoseofexcel.com/?s=closed+workbook
They have discussed this issue several times
Hello
In a sheet where each column has different conditional formatting, is it possible, in VBA, to merge cells vertically without loosing the conditionnal formatting?
Thank you
Hi thank you very much for the macro, that is a gem!!!
I wanted to know if instead of using selection but if i would like to add a preset range, how do i rewrite the code for this?
For example?
instead of "For Each cell In Selection"
i would like to merge data in a predetermined cell that will not moved.
A1: Apple
A2: orange
A3: banana
A4: Chocolate
A5: Coffee
A6: Tea
A7: Red
A8: Pink
A9: yellow
to become:
apple orange banana <-- as one cell
chocolate coffee tea <-- as one cell
red pink yellow <-- as one cell
Can you pleaseee help me? thank youuuu
how do i do this?
Works Perfectly for me 🙂
Hello Chandoo, this macro works great for my spreadsheet needs, however, a column with several ranges [+5,000] of rows that are needed to apply this VBA takes a lot of time and effort, so deciding to use a colored and alternated background for each range in order to visualize which range needs to be joined and merged easily, is there a way on the VBA to grab each range with the same background to run the VBA and continue with the next range on the different background color until it runs to the end of the last row/range? Thank you.
I have conditional formatting relying on a date where the cell is merged because I had to add another row in order to have the sub contractors listed separately. For example, I have rows 2 and 3 for a task and columns A, B, C, D, E, F, G, H, I, J, K, L, M, N, O and P are all merged however once you get to column Q, R, S, T, U they are no longer merged to show the distinction between the 2 different sub contractors on the task. Column V is merged again. My problem is Column I which is the expiration date of the task is the condition to turn all the cells to the color requested. Because column I is merged the first subcontractor in Row 2, Column Q, R, S, T, U will turn the color but the second sub contractor in Row 3, Column Q, R, S, T and U will not turn the color requested. It will only happen if I don't merge the Column I which has the expiration date and I put the date in both cells (2 and 3). PLEASE HELP IVE BEEN WORKING ON THIS FOR 3 DAYS!!!!!!
Reply
Dear all
how I repeat the word with simple shortcut how I create a macro in it. Like "Pakistani is great" this line is use many time in my sheet how can I make shortcut for it??
thank you so much , fill and justify function helped me and saved lot of time..
thank you .....??
I get in the above cases, the content is being merged from multiple cells into one cell, but how can you merge the content of multiple cells WITHOUT losing the format of the text in those multiple cells into one cell, especially if the final result will result in having more than 255 characters, thus the TEXT property of the CHARACTERS object on the final cell will NOT be available.