Excluding Sections of a Auto-Generated Narrative Report

  • Hi all,


    I've slowly been chipping away at a report generator developed in Excel (using VBA) that will allow me to generate a narrative report based on exam scores.


    It seems to be working for the most part; however, what I am trying to do now is exclude sections of the narrative if scores for certain courses are not entered in the table (ie., left blank, as not all students may have taken all of the tests).


    For example, I have a table with two columns: The test, and a score in percentage points for that test. If there is no score for English, for instance, the VBA will generate a sentence, but with no score value. I would like to eliminate that sentence entirely if a score for English is left blank.


    Excel Workbook: XLSX Sample Workbook

  • Hello,


    A couple of remarks :


    1. Why is your attached file not including any macro ?


    2. The macro you have posted does not seem to be the one you are actually using to generate the report with the scores in cells B6- B10


    3. Building your comment string, you will need to use the vba IIF function


    see explanation : https://www.excelfunctions.net/vba-iif-function.html


    Hope this will help

    :)

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Thumbs Up" icon, below, in the bottom right corner:)

  • Hi Carim, thank you for the helpful tips! I was actually going to re-post with the Macro-enabled Excel workbook, but the link you provided has all the info I need to solve the issue I'm having :).


    Also, I posted the VBA code separately from the workbook because I was castigated on Stack Overflow, as they said "it could be a virus for all we know". This thread was MUCH more helpful. Thanks again!

  • Hi,


    Have you managed to fix your problem with IIF ... ???


    If not, do not hesitate to come back to the Forum ;)

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Thumbs Up" icon, below, in the bottom right corner:)

  • Pleased to hear you have managed to fix your problem :)


    Thanks a lot for your Thanks ...AND for the Like :thumbup:

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Thumbs Up" icon, below, in the bottom right corner:)