View Single Post
 
Old 09-01-2015, 07:00 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by Echevca View Post
I have clients with different set of products. For simplicity purposes lets pretend the products are called A, B, C, D. Not all clients have all four products. Client #1, for example only has products A and B; Client#2 only has product B and Client #3 only has products C and D.

My Excel file will look like this:


Client Product A Product B Product C Product D
Client 1 1% 2%
Client 2 2%
Client 3 3% 4%

I want to put a letter together that reference the % increase each product will incur without having to list all four products as a template and avoid spaces between the lines when there is no product. For example. the letter for carriers #1 will say that they are getting an increase for products A and B while the letter for Carrier #2 will say they are getting an increase for product. B....they will not see the other products listed since they don't have a % marked in the Excel file.
Assuming you want lists like:

Client 1
Product A : %
Product C : %
Product D : %

Client 2
Product B : %
Product D : %

Client 3
Product A : %
Product B : %
Product C : %
Product D : %

you don't need IF tests! Try:
{MERGEFIELD Product_A \b "Product A : "}{MERGEFIELD Product_B \b "¶
Product B : "}{MERGEFIELD Product_C \b "¶
Product C : "}{MERGEFIELD Product_D \b "¶
Product D : "}¶
where ¶ is an actual paragraph break or line break.

To conditionally output a whole table row, though, you would need IF tests but, unless you want to make things very complicated (so as to account for every possible combination), your output will generate a series of one-row tables. The one-row table approach uses fields like:
|Product|Current Price|New Price|
{IF{MERGEFIELD Product_A}<> "|{MERGEFIELD Product_A}|{MERGEFIELD Current_Price_A}|{MERGEFIELD New_Price_A}|¶
"}{IF{MERGEFIELD Product_B}<> "|{MERGEFIELD Product_B}|{MERGEFIELD Current_Price_B}|{MERGEFIELD New_Price_B}|¶
"}
etc., where the | characters represent table cell borders.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote