邮件从Excel合并到Word将多行作为一个记录处理

时间:2013-05-17 14:04:01

标签: excel merge ms-word mailmerge

我正在尝试创建代码,以便在Excel到Word邮件合并期间执行以下操作。

拥有以下数据:

ID  EV  DI  SE  PR
1   A   D   A   10
1   A   D   A   10
1   A   E   B   5
1   B   D   C   15
1   C   D   D   20
2   B   D   C   15
2   B   D   C   15
2   C   F   D   25
3   A   E   B   5
3   B   D   C   15
3   C   F   D   25
3   C   F   D   25

Where 
ID = Patron ID
EV = Event
DI = Discount
SE = Section
PR = Price

我需要合并,如下所示,其中唯一赞助人ID被归类为一个记录。

MERGEFIELD Patron ID
MERGEFIELD Event (where event name is A)
COUNT Discount WHERE Discount is D MERGEFIELD Discount MERGEFIELD Section @ MERGEFIELD Price
COUNT Discount WHERE Discount is E MERGEFIELD Discount MERGEFIELD Section @ MERGEFIELD Price
MERGEFIELD Event Name (where event name is B)

哪会产生结果:

  

记录1
1
A
2 D A @ 10
1 E B @ 5

B
1   D C @ 15

C
1 D D @ 20

下一条记录

  

记录2
2
B b 2 D C @ 15

C
1 F D @ 25

我找到了这段代码,但我很难将它应用到这种情况中,并且还想知道如何在内部使用它来突破事件。

{ IF { MERGESEQ } = "1" "{ MERGEFIELD CITY }¶
" "" }{ SET Place1 { MERGEFIELD CITY }}¶
{ If { Place2 } <> { Place1 }"¶
{ MERGEFIELD CITY }¶
¶
{ MERGEFIELD EMPLOYEE } { MERGEFIELD SALES }" "{ MERGEFIELD EMPLOYEE } { MERGEFIELD SALES }" }{ SET Place2 { MERGEFIELD CITY }}¶`" "" }{ SET Place1 { MERGEFIELD CITY }}¶

`

0 个答案:

没有答案