The idea of mail merge is simple & powerful. Imagine you handle recruitment at a large company. You just hired 300 analysts for the big data division. The next job – generate employment offer letters for each of them. Of course, you don’t want to type these letters one at a time. You have the details of all the 300 offers (name, email, address, offer code, role, benefit package details and date of joining etc.) in a spreadsheet. You also have a template of the offer letter.
Enter mail merge. This powerful feature combines MS Word documents with (Excel) data to generate all the 300 letters in just few minutes.

You can use mail merge in many similar situations – like generating invoices, address labels, certificates etc.
Read the below tutorial to learn how to set up mail merge in Word.
Tutorial – using mail merge to generate invoices
For this tutorial, let’s pick the example of generating invoices.
Step 1 – Create a workbook with your data
Let’s say your invoice has 11 fields, as shown below.

Create a workbook with 11 columns and load data as shown below.

Step 2 – Create an invoice template in MS Word
Open a new document in MS Word and create a document structure that reflects your invoice. You may download the invoice template for inspiration.
At this stage, our invoice looks like this:

Step 3 – Activate Mail Merge

Go to Mailings ribbon in MS Word and click on “Start mail merge” button. Choose the document type that best describes what you are doing (for invoices, you can choose either letter or normal word document)

This activates mail merge mode on your document.
Step 4 – Load data

Now, we need to load the field data. Click on “Select recipients” and choose “Use an existing list”. This opens File>Open dialog. Navigate to the folder where you saved Excel workbook with invoice data and select the file.
Step 5 – Insert fields at right places
Now that we have a list of fields, load them at necessary location in the invoice template using the “Insert Merge Field” button.
Pro tip: You can use Rules option to set up If then rules based on field values. (for example, if the payment reference # is empty, you can show different text)
At this stage, our invoice looks like this:

Step 6 – Preview & complete mail merge

Using the preview results area, check if everything is ok. Once you are ready, click on “Finish & Merge” to generate individual word documents or emails or prints of the invoices.
Pro tip: If you have a PDF printer, you can use that to generate PDFs for each invoice automatically.
Download Mail Merge tutorial files
There are 2 files in this tutorial – Excel workbook with invoice data & Word document with mail merge setup.
After downloading the files:
- Place them in the same folder.
- Open the Word document.
- At this point, you should get an error. Click ok.
- This will open Data link properties dialog.
- Type the full path of the downloaded Excel workbook in the Data source field. Click ok (see image).
- This should establish the connection for you.
Do you mail merge?
Mail merge is a very powerful and time saving feature. I use it often when I need to generate a lot of documents in one go.
What about you? Do you use mail merge? Please share your experiences & tips in the comments section.














12 Responses to “Analyzing Search Keywords using Excel : Array Formulas in Real Life”
Very interesting Chandoo, as always. Personally I find endless uses for formulae such as {=sum(if(B$2:B$5=$A2,$C$2$C$5))}, just the flexibility in absolute and relative relative referencing and multiple conditions gives it the edge over dsum and others methods.
I've added to my blog a piece on SQL in VBA that I think might be of interest to you http://aviatormonkey.wordpress.com/2009/02/10/lesson-one-sql-in-vba/ . It's a bit techie, but I think you might like it.
Keep up the good work, aviatormonkey
Hi Chandoo,
You might find this coded solution I posted on a forum interesting.
http://www.excelforum.com/excel-programming/680810-create-tag-cloud-in-vba-possible.html
[...] under certain circumstances. One of the tips involved arranging search keywords in excel using Array Forumlas. Basically, if you need to know how frequent a word or group of keywords appear, you can use this [...]
@Aviatormonkey: Thanks for sharing the url. I found it a bit technical.. but very interesting.
@Andy: Looks like Jarad, the person who emailed me this problem has posted the same in excelforum too. Very good solution btw...
Realy great article
"You can take this basic model and extend it to include parameters like number of searches each key phrase has, how long the users stay on the site etc. to enhance the way tag cloud is generated and colored."
How would you go about doing this? I think it would need some VB
Hi,
I found the usage very interesting, but is giving me hard time because the LENs formula that use ranges are not considering the full range, in other words, the LEN formula is only bringing results from the respective "line" cell.
Using the example, when I place the formula to calculate the frequency for "windows" brings me only 1 result, not 11 as displayed in the example. It seems that the LEN formula using ranges is considering the respective line within the range, not the full range.
Any hint?
@Thiago
You have to enter the formula as an Array Formula
Enter the Formula and press Ctrl+Shift+Enter
Not just Enter
Thank you, Hui! I couldn't work out how this didn't work
is there a limit to the number of lines it can analyse.
Ie i am trying to get this to work on a list of sentances 1500 long.
@Gary
In Excel 2010/2013 Excel is only limited by available memory,
So just give it a go
As always try on a copy of the file first if you have any doubts
Apologies if I am missing something, but coudn't getting frequency be easier with Countif formula. Something like this - COUNTIF(Range with text,"*"&_cell with keyword_&"*")
Apologies if I missed, but what is the Array Formula to:
1. Analyze a list of URL's or a list of word phrases to understand frequency;
2. List in a nearby column from most used words to least used words;
3. Next to the list of words the count of occurrences.