Mail Merge Multiple Rows into one based on multiple columns

cochranb13

New Member
Joined
Feb 29, 2020
Messages
6
Office Version
  1. 365
Platform
  1. MacOS
I am trying to create a mail merge that I can send to staff weekly that gives them individual data along with ONLY names of students that are failing. I have searched and found how to combine rows using one condition and a compare column, but I do not understand the syntax well enough to know how to include a second condition.



I have included screenshots below of data sheet, what I am getting when I run merge, what I want when I run merge, and what I have entered in merge.
 

Attachments

  • Screen Shot 2020-02-29 at 3.47.50 PM.png
    Screen Shot 2020-02-29 at 3.47.50 PM.png
    164.9 KB · Views: 481
  • Screen Shot 2020-02-29 at 3.47.45 PM.png
    Screen Shot 2020-02-29 at 3.47.45 PM.png
    164.1 KB · Views: 478
  • Screen Shot 2020-02-29 at 8.21.23 PM.png
    Screen Shot 2020-02-29 at 8.21.23 PM.png
    176.1 KB · Views: 476

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Hi,

I have a suggestion for you

create a column in your DB and use this formula in it:
Code:
=TEXTJOIN(CHAR(10),TRUE,IF(LEFT([Score])="f",[student full],""))

use this formula as an array formula
 
Upvote 0
It's not apparent to me where you're getting the data for «A», «B», «C», etc. from as nothing in your Excel screenshot is capable of generating that for a mailmerge.

As for the grouping, you can use Word's Catalogue/Directory Mailmerge facility (the terminology depends on the Word version). To see how to do so with any mailmerge data source supported by Word, check out my Microsoft Word Catalogue/Directory Mailmerge Tutorial at:
or:
The tutorial covers everything from list creation to the insertion & calculation of values in multi-record tables in letters. Do read the tutorial before trying to use the mailmerge document included with it.

Depending on what you're trying to achieve, the field coding for this can be complex. However, since the tutorial document includes working field codes for all of its examples, most of the hard work has already been done for you - you should be able to do little more than copy/paste the relevant field codes into your own mailmerge main document, substitute/insert your own field names and adjust the formatting to get the results you desire. For some worked examples, see the attachments to the posts at:

Another option would be to use a DATABASE field in a normal ‘letter’ mailmerge main document and a macro to drive the process. An outline of this approach can be found at: Many to one email merge using tables
Conversely, if you're using a relational database or, Excel workbook with a separate table with just a single instance of each of the grouping criteria, a DATABASE field in a normal ‘letter’ mailmerge main document could be used without the need for a macro. An outline of this approach can be found at:
For some working examples, see:
The DATABASE field can even be used without recourse to a mailmerge. An example of such usage can be found at: Mail merge into different coloumns

Alternatively, you may want to try one of the Many-to-One Mail Merge add-ins, from:
Graham Mayor at Merge Many To One ; or
Doug Robbins at OneDrive
 
Upvote 0
It's not apparent to me where you're getting the data for «A», «B», «C», etc. from as nothing in your Excel screenshot is capable of generating that for a mailmerge.

As for the grouping, you can use Word's Catalogue/Directory Mailmerge facility (the terminology depends on the Word version). To see how to do so with any mailmerge data source supported by Word, check out my Microsoft Word Catalogue/Directory Mailmerge Tutorial at:
or:
The tutorial covers everything from list creation to the insertion & calculation of values in multi-record tables in letters. Do read the tutorial before trying to use the mailmerge document included with it.

Depending on what you're trying to achieve, the field coding for this can be complex. However, since the tutorial document includes working field codes for all of its examples, most of the hard work has already been done for you - you should be able to do little more than copy/paste the relevant field codes into your own mailmerge main document, substitute/insert your own field names and adjust the formatting to get the results you desire. For some worked examples, see the attachments to the posts at:

Another option would be to use a DATABASE field in a normal ‘letter’ mailmerge main document and a macro to drive the process. An outline of this approach can be found at: Many to one email merge using tables
Conversely, if you're using a relational database or, Excel workbook with a separate table with just a single instance of each of the grouping criteria, a DATABASE field in a normal ‘letter’ mailmerge main document could be used without the need for a macro. An outline of this approach can be found at:
For some working examples, see:
The DATABASE field can even be used without recourse to a mailmerge. An example of such usage can be found at: Mail merge into different coloumns

Alternatively, you may want to try one of the Many-to-One Mail Merge add-ins, from:
Graham Mayor at Merge Many To One ; or
Doug Robbins at OneDrive
The data for the As, Bs, Cs, etc is coming from columns not included in screenshot.
 
Upvote 0
Hi,

I have a suggestion for you

create a column in your DB and use this formula in it:
Code:
=TEXTJOIN(CHAR(10),TRUE,IF(LEFT([Score])="f",[student full],""))

use this formula as an array formula

Ok. Being unfamiliar with the advanced Excel and Mail Merge things, what would I do with this new column?
 
Upvote 0
Ok. Being unfamiliar with the advanced Excel and Mail Merge things, what would I do with this new column?

You just need to create a new column and copy this formula in it. but after copy it, instead of press Enter key you should press ctrl+shift+enter keys.
and in Word just add this column in your paper.
 
Upvote 0
You just need to create a new column and copy this formula in it. but after copy it, instead of press Enter key you should press ctrl+shift+enter keys.
and in Word just add this column in your paper.

I added Column and made Array Formula and it copied only Failing Student Names over; however, when I run mail merge I still either get all students for a teacher or no students. I cannot get the merge to pull just the failing student names.
 
Upvote 0
Here is Excel data
Merge Help.xlsx
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACAD
1State IDStudent NumberLast NameFirst NameStudent FullBirthdateCohort Year NGAGradeCourse NumberSection NumberPeriod StartCourse NameScorePercentTaskTerm StartTeacher Full NameCompareMerge HelpTeacherr individualBlank GradesPostedPosting %EmailABCDFPass Rate
2123456789123456Last1First1First1 Last11/1/0220201212343123class 1A-92.12Progress/EligibilityS2Teacher 1Teacher 1 Teacher 1018100%teacher1@email.com3552383.3%
3123456790123457Last2First2First2 Last21/1/0220201312343123class 1C+79.42Progress/EligibilityS2Teacher 1Teacher 1 Teacher 2018100%teacher2@email.com4532477.8%
4123456791123458Last3First3First3 Last31/1/0220201412343123class 1B+86.5Progress/EligibilityS2Teacher 1Teacher 1 Teacher 3018100%teacher3@email.com7712194.4%
5123456792123459Last4First4First4 Last41/1/0220201512343123class 1C75.97Progress/EligibilityS2Teacher 1Teacher 1 Teacher 4016100%teacher4@email.com5331475.0%
6123456793123460Last5First5First5 Last51/1/0220201612343123class 1B85.39Progress/EligibilityS2Teacher 1Teacher 1 
7123456794123461Last6First6First6 Last61/1/0220201712343123class 1F65.66Progress/EligibilityS2Teacher 1Teacher 1First6 Last6
8123456795123462Last7First7First7 Last71/1/0220201812343123class 1C-71.38Progress/EligibilityS2Teacher 1Teacher 1 
9123456796123463Last8First8First8 Last81/1/0220201912343123class 1A95.09Progress/EligibilityS2Teacher 1Teacher 1 
10123456797123464Last9First9First9 Last91/1/0220202012343123class 1C-69.6Progress/EligibilityS2Teacher 1Teacher 1 
11123456798123465Last10First10First10 Last101/1/0220202112343123class 1F83.95Progress/EligibilityS2Teacher 1Teacher 1First10 Last10
12123456799123466Last11First11First11 Last111/1/0220202212343123class 1D66.54Progress/EligibilityS2Teacher 1Teacher 1 
13123456800123467Last12First12First12 Last121/1/0220202312343123class 1B-81.32Progress/EligibilityS2Teacher 1Teacher 1 
14123456801123468Last13First13First13 Last131/1/0220202412343123class 1C-72.23Progress/EligibilityS2Teacher 1Teacher 1 
15123456802123469Last14First14First14 Last141/1/0220202512343123class 1B85.15Progress/EligibilityS2Teacher 1Teacher 1 
16123456803123470Last15First15First15 Last151/1/0220202612343123class 1F89.47Progress/EligibilityS2Teacher 1Teacher 1First15 Last15
17123456804123471Last16First16First16 Last161/1/0220202712343123class 1D68.83Progress/EligibilityS2Teacher 1Teacher 1 
18123456805123472Last17First17First17 Last171/1/0220202812343123class 1A92.96Progress/EligibilityS2Teacher 1Teacher 1 
19123456806123473Last18First18First18 Last181/1/0220202912343123class 1B-81.9Progress/EligibilityS2Teacher 1Teacher 1 
20123456789123456Last1First1First1 Last11/1/0220201212347127class 2D101Progress/EligibilityS3Teacher 2Teacher 2 
21123456790123457Last2First2First2 Last21/1/0220201312347127class 3F102Progress/EligibilityS4Teacher 2Teacher 2First2 Last2
22123456791123458Last3First3First3 Last31/1/0220201412347127class 4B+103Progress/EligibilityS5Teacher 2Teacher 2 
23123456792123459Last4First4First4 Last41/1/0220201512347127class 5C-104Progress/EligibilityS6Teacher 2Teacher 2 
24123456793123460Last5First5First5 Last51/1/0220201612347127class 6A105Progress/EligibilityS7Teacher 2Teacher 2 
25123456794123461Last6First6First6 Last61/1/0220201712347127class 7B+106Progress/EligibilityS8Teacher 2Teacher 2 
26123456795123462Last7First7First7 Last71/1/0220201812347127class 8A107Progress/EligibilityS9Teacher 2Teacher 2 
27123456796123463Last8First8First8 Last81/1/0220201912347127class 9F108Progress/EligibilityS10Teacher 2Teacher 2First8 Last8
28123456797123464Last9First9First9 Last91/1/0220202012347127class 10F109Progress/EligibilityS11Teacher 2Teacher 2First9 Last9
29123456798123465Last10First10First10 Last101/1/0220202112347127class 11A-110Progress/EligibilityS12Teacher 2Teacher 2 
30123456799123466Last11First11First11 Last111/1/0220202212347127class 12A-111Progress/EligibilityS13Teacher 2Teacher 2 
31123456800123467Last12First12First12 Last121/1/0220202312347127class 13F112Progress/EligibilityS14Teacher 2Teacher 2First12 Last12
32123456801123468Last13First13First13 Last131/1/0220202412347127class 14B113Progress/EligibilityS15Teacher 2Teacher 2 
33123456802123469Last14First14First14 Last141/1/0220202512347127class 15C114Progress/EligibilityS16Teacher 2Teacher 2 
34123456803123470Last15First15First15 Last151/1/0220202612347127class 16B+115Progress/EligibilityS17Teacher 2Teacher 2 
35123456804123471Last16First16First16 Last161/1/0220202712347127class 17C+116Progress/EligibilityS18Teacher 2Teacher 2 
36123456805123472Last17First17First17 Last171/1/0220202812347127class 18B+117Progress/EligibilityS19Teacher 2Teacher 2 
37123456806123473Last18First18First18 Last181/1/0220202912347127class 19D118Progress/EligibilityS20Teacher 2Teacher 2 
38123456789123456Last1First1First1 Last11/1/0220201212347127class 27A126Progress/EligibilityS28Teacher 3Teacher 3 
39123456790123457Last2First2First2 Last21/1/0220201312347127class 28A127Progress/EligibilityS29Teacher 3Teacher 3 
40123456791123458Last3First3First3 Last31/1/0220201412347127class 29A128Progress/EligibilityS30Teacher 3Teacher 3 
41123456792123459Last4First4First4 Last41/1/0220201512347127class 30B+129Progress/EligibilityS31Teacher 3Teacher 3 
42123456793123460Last5First5First5 Last51/1/0220201612347127class 31B130Progress/EligibilityS32Teacher 3Teacher 3 
43123456794123461Last6First6First6 Last61/1/0220201712347127class 32B+131Progress/EligibilityS33Teacher 3Teacher 3 
44123456795123462Last7First7First7 Last71/1/0220201812347127class 33B-132Progress/EligibilityS34Teacher 3Teacher 3 
45123456796123463Last8First8First8 Last81/1/0220201912347127class 34A133Progress/EligibilityS35Teacher 3Teacher 3 
46123456797123464Last9First9First9 Last91/1/0220202012347127class 35B+134Progress/EligibilityS36Teacher 3Teacher 3 
47123456798123465Last10First10First10 Last101/1/0220202112347127class 36D135Progress/EligibilityS37Teacher 3Teacher 3 
48123456799123466Last11First11First11 Last111/1/0220202212347127class 37F136Progress/EligibilityS38Teacher 3Teacher 3First11 Last11
49123456800123467Last12First12First12 Last121/1/0220202312347127class 38D137Progress/EligibilityS39Teacher 3Teacher 3 
50123456801123468Last13First13First13 Last131/1/0220202412347127class 39A138Progress/EligibilityS40Teacher 3Teacher 3 
51123456802123469Last14First14First14 Last141/1/0220202512347127class 40B+139Progress/EligibilityS41Teacher 3Teacher 3 
52123456803123470Last15First15First15 Last151/1/0220202612347127class 41C-140Progress/EligibilityS42Teacher 3Teacher 3 
53123456804123471Last16First16First16 Last161/1/0220202712347127class 42A141Progress/EligibilityS43Teacher 3Teacher 3 
54123456805123472Last17First17First17 Last171/1/0220202812347127class 43B+142Progress/EligibilityS44Teacher 3Teacher 3 
55123456789123456Last1First1First1 Last11/1/0220201212347127class 44A143Progress/EligibilityS45Teacher 3Teacher 3 
56123456790123457Last2First2First2 Last21/1/0220201312347127class 80A179Progress/EligibilityS81Teacher 4Teacher 4 
57123456791123458Last3First3First3 Last31/1/0220201412347127class 81F180Progress/EligibilityS82Teacher 4Teacher 4First3 Last3
58123456792123459Last4First4First4 Last41/1/0220201512347127class 82F181Progress/EligibilityS83Teacher 4Teacher 4First4 Last4
59123456793123460Last5First5First5 Last51/1/0220201612347127class 83A-182Progress/EligibilityS84Teacher 4Teacher 4 
60123456794123461Last6First6First6 Last61/1/0220201712347127class 84A-183Progress/EligibilityS85Teacher 4Teacher 4 
61123456795123462Last7First7First7 Last71/1/0220201812347127class 85F184Progress/EligibilityS86Teacher 4Teacher 4First7 Last7
62123456796123463Last8First8First8 Last81/1/0220201912347127class 86B185Progress/EligibilityS87Teacher 4Teacher 4 
63123456797123464Last9First9First9 Last91/1/0220202012347127class 87C186Progress/EligibilityS88Teacher 4Teacher 4 
64123456798123465Last10First10First10 Last101/1/0220202112347127class 88B+187Progress/EligibilityS89Teacher 4Teacher 4 
65123456799123466Last11First11First11 Last111/1/0220202212347127class 89C+188Progress/EligibilityS90Teacher 4Teacher 4 
66123456800123467Last12First12First12 Last121/1/0220202312347127class 90B+189Progress/EligibilityS91Teacher 4Teacher 4 
67123456801123468Last13First13First13 Last131/1/0220202412347127class 91D190Progress/EligibilityS92Teacher 4Teacher 4 
68123456802123469Last14First14First14 Last141/1/0220202512347127class 92A-191Progress/EligibilityS93Teacher 4Teacher 4 
69123456803123470Last15First15First15 Last151/1/0220202612347127class 93F192Progress/EligibilityS94Teacher 4Teacher 4First15 Last15
70123456804123471Last16First16First16 Last161/1/0220202712347127class 94A-193Progress/EligibilityS95Teacher 4Teacher 4 
71123456805123472Last17First17First17 Last171/1/0220202812347127class 95C194Progress/EligibilityS96Teacher 4Teacher 4 
Data
Cell Formulas
RangeFormula
R2:R71R2=Q2
S2:S71S2=TEXTJOIN(CHAR(10),TRUE,IF(LEFT(M2)="f",E2,""))
U2:U5U2=COUNTIFS($Q:$Q,$T2,$M:$M,"")
V2:V5V2=COUNTIFS($Q:$Q,$T2,$M:$M,"*")
W2:W5W2=V2/(U2+V2)
Y2:Y5Y2=COUNTIFS($Q:$Q,$T2,$M:$M,"A*")
Z2:Z5Z2=COUNTIFS($Q:$Q,$T2,$M:$M,"B*")
AA2:AA5AA2=COUNTIFS($Q:$Q,$T2,$M:$M,"C*")
AB2:AB5AB2=COUNTIFS($Q:$Q,$T2,$M:$M,"D*")
AC2:AC5AC2=COUNTIFS($Q:$Q,$T2,$M:$M,"F")
AD2:AD5AD2=IF(W2=0,"No Grades Posted",(1-(AC2/((SUM(U2:V2))))))
E2:E71E2=CONCATENATE(D2," ",C2)


I need merge to Generate separate emails to Teacher 1, 2, 3, and 4 that tells them their individual grade data and lists only student failing their course. Students with A, B, C, or D should not be listed in email.
 
Upvote 0

Forum statistics

Threads
1,223,601
Messages
6,173,293
Members
452,508
Latest member
SaltySquid

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top