Consulting

Results 1 to 2 of 2

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

  1. #1
    VBAX Newbie
    Joined
    Jan 2015
    Posts
    1
    Location

    Add or delete a paragraph based on an empty cell in an excel spreadsheet please help

    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
    Last edited by jujufr; 01-14-2015 at 11:00 PM. Reason: want to be nice

  2. #2
    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.
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes
    http://www.gmayor.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •