MailMerge Issue

siddo

Board Regular
Joined
May 26, 2020
Messages
106
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
is it possible to do a mail merge only if a cell value in excel is marked as "Yes" and if the cell value is marked as "No" delete the bookmarked sentence in word. I want to put in dates in word file if the value is excel is "Yes" else I want to delete the sentence.

For example - Siddo carried out his work from xxxx to xxxx date (Template in Word). Cell value in Excel Column A - Siddo carried out work. Column B- "Yes". select date from Column C and paste it in word template. if Column B is "No" then delete the word template
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Yes, that kind of thing is quite easy, using an IF field. Such a field might be coded along the lines of:

{IF«YesNo»= "Yes" "«Employee» carried out his work from «StartDate» to «EndDate» date.¶
"}

Note: The field brace pairs (i.e. '{ }') for the above example are all created in the document itself, via Ctrl-F9 (Cmd-F9 on a Mac or, if you’re using a laptop, you might need to use Ctrl-Fn-F9); you can't simply type them or copy & paste them from this message. Nor is it practical to add them via any of the standard Word dialogues. Likewise, the chevrons (i.e. '« »') are part of the actual mergefields - which you can insert from the 'Insert Merge Field' dropdown (i.e. you can't type or copy & paste them from this message, either). The spaces represented in the field constructions are all required. Instead of the ¶ symbol, you should use a real paragraph break (assuming one is required).

For more useful hints, check out the Mailmerge Tips and Tricks thread at: Mailmerge Tips & Tricks
 
Upvote 0
Solution
Yes but the cache here is I want mail merge to pick Yes or No value from excel cells and then do the work. if there is Yes in the excel cell value then put in the dates and if there is no then remove the sentence from word
 
Upvote 0
Yes but the cache here is I want mail merge to pick Yes or No value from excel cells and then do the work. if there is Yes in the excel cell value then put in the dates and if there is no then remove the sentence from word
Which is exactly what the Word field coding I described does...

All you need do is supply your own field names.
 
Upvote 0
Which is exactly what the Word field coding I described does...

All you need do is supply your own field names.
In the above code, if you could me with the particular line of code which deletes the sentence if it doesnt find "Yes" as an option?
 
Upvote 0
Yes apologies I got your point, but is there a way to use nested "if else"?
 
Upvote 0
I got it thanks, Just last doubt I had if I want to minus that date suppose for example today is 3/31/2022 and I minus it by -1 year so it possible to show 3/31/2022 - 1 as 3/31/2021
 
Upvote 0
Yes, that too is possible. To see how to do this and just about everything else you might want to do with dates in Word, check out the Calculate a day, date, month and year, using n years delay and Date and Time Calculations In A Mailmerge topics my Microsoft Word Date Calculation Tutorial, available at: Microsoft Word Date Calculation Tutorial. Do read the document's introductory material.
 
Upvote 0

Forum statistics

Threads
1,224,824
Messages
6,181,186
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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