PDA

View Full Version : Add or delete a paragraph based on an empty cell in an excel spreadsheet please help



jujufr
01-14-2015, 10:59 PM
Hi all .... I know I am new here ... I used to study VB a very long time ago but have long since forgotten much of it

I would greatly appreciate any assistance that could be given

I have a proposal document in Word 2007 and am having trouble figuring out how to remove a paragraph based on whether a cell has a value in a corresponding excel file (or potentially in the same document)

The document populates from a mailmerge - this includes pricing from the excel file

I want to delete paragraphs or bullet points based on whether there is matched information in the excel file or the pricing table ..... eg

TV is 46" LCD
TV is 52" LCD

Price is
$599
$799

If the $599 price is not there I want to remove the description of TV 46"LCD

gmayor
01-15-2015, 12:09 AM
How is the worksheet used for the merge data arranged?

Mail merge only works with a flat file where each record takes up a single row, though you could investigate http://www.gmayor.com/ManyToOne.htm if you want to merge several lines associated with a single key field.

With a conventional one to one merge, you can conditionally introduce data using fields in the merge document e.g.

{ IF { MERGEFIELD Price1 } <> "" "¶
• { MERGEFIELD Description1 }[TAB]{ MERGEFIELD Price1 }" }{ IF { MERGEFIELD Price2 } <> "" "¶
• { MERGEFIELD Description2 }[TAB]{ MERGEFIELD Price2 }" }etc

¶ = Press the Enter key
[TAB] = "Press the Tab key
• = a bullet character
{ } Inserted with CTRL+F9

If you are creating a custom function using VBA then we would need a lot more information before being able to provide any assistance.