HTML adjustment per line

Hi,

I'm trying to do some adjustments on this HTML code in order to paste it in Excel and give the values that have the title="Included a red color.

What I want to achieve:

  1. First create a line break between "&nbsp;" AND "</td><td id=" (I assume that I need this to use the if /else condition where the variable lineText starts with <td id=. Because with the contain option it's not working.

  2. Then I need to some regular expression to add the style element with colour red to the line.

I hope I've make myself clear :wink:

Current Macro:

Here is the html block:

<div><table id="matrix" cellpadding="0" cellspacing="0" onmouseup="picklistSetup.handleMouseUp(event)" onmousedown="picklistSetup.handleMouseDown(event)" style="width:99.8%"><tbody><tr><th class="topSelectHeader" width="8%">&nbsp;Status:&nbsp;</th><th id="th_r0c0" class="selectHeader" onclick="picklistSetup.selectColumn(0)" width="16%">&nbsp;Prospect&nbsp;</th><th id="th_r0c1" class="selectHeader" onclick="picklistSetup.selectColumn(1)" width="16%">&nbsp;Onboarding&nbsp;</th><th id="th_r0c2" class="selectHeader" onclick="picklistSetup.selectColumn(2)" width="16%">&nbsp;Client&nbsp;</th><th id="th_r0c3" class="selectHeader" onclick="picklistSetup.selectColumn(3)" width="16%">&nbsp;Active&nbsp;</th><th id="th_r0c4" class="selectHeader" onclick="picklistSetup.selectColumn(4)" width="16%">&nbsp;Inactive&nbsp;</th></tr><tr><th class="topSelectHeader" rowspan="10">&nbsp;Reason Inactive:&nbsp;</th><td id="te_r0c0" class="hiddenPickValue" title="Excluded: Status: Prospect" onmousedown="picklistSetup.handleClick(event,this)" ondblclick="picklistSetup.handleDblClick(event,this)" onmousemove="picklistSetup.handleMouseMove(event,this)">&nbsp;6 Months No Interaction&nbsp;</td><td id="te_r0c1" class="hiddenPickValue" title="Excluded: Status: Onboarding" onmousedown="picklistSetup.handleClick(event,this)" ondblclick="picklistSetup.handleDblClick(event,this)" onmousemove="picklistSetup.handleMouseMove(event,this)">&nbsp;6 Months No Interaction&nbsp;</td><td id="te_r0c2" class="hiddenPickValue" title="Excluded: Status: Client" onmousedown="picklistSetup.handleClick(event,this)" ondblclick="picklistSetup.handleDblClick(event,this)" onmousemove="picklistSetup.handleMouseMove(event,this)">&nbsp;6 Months No Interaction&nbsp;</td><td id="te_r0c3" class="hiddenPickValue" title="Excluded: Status: Active" onmousedown="picklistSetup.handleClick(event,this)" ondblclick="picklistSetup.handleDblClick(event,this)" onmousemove="picklistSetup.handleMouseMove(event,this)">&nbsp;6 Months No Interaction&nbsp;</td><td id="te_r0c4" class="hiddenPickValue" title="Excluded: Status: Inactive" onmousedown="picklistSetup.handleClick(event,this)" ondblclick="picklistSetup.handleDblClick(event,this)" onmousemove="picklistSetup.handleMouseMove(event,this)">&nbsp;6 Months No Interaction&nbsp;</td></tr><tr><td id="te_r1c0" class="hiddenPickValue" title="Excluded: Status: Prospect" onmousedown="picklistSetup.handleClick(event,this)" ondblclick="picklistSetup.handleDblClick(event,this)" onmousemove="picklistSetup.handleMouseMove(event,this)">&nbsp;Bankrupt&nbsp;</td><td id="te_r1c1" class="hiddenPickValue" title="Excluded: Status: Onboarding" onmousedown="picklistSetup.handleClick(event,this)" ondblclick="picklistSetup.handleDblClick(event,this)" onmousemove="picklistSetup.handleMouseMove(event,this)">&nbsp;Bankrupt&nbsp;</td><td id="te_r1c2" class="hiddenPickValue" title="Excluded: Status: Client" onmousedown="picklistSetup.handleClick(event,this)" ondblclick="picklistSetup.handleDblClick(event,this)" onmousemove="picklistSetup.handleMouseMove(event,this)">&nbsp;Bankrupt&nbsp;</td><td id="te_r1c3" class="hiddenPickValue" title="Excluded: Status: Active" onmousedown="picklistSetup.handleClick(event,this)" ondblclick="picklistSetup.handleDblClick(event,this)" onmousemove="picklistSetup.handleMouseMove(event,this)">&nbsp;Bankrupt&nbsp;</td><td id="te_r1c4" class="shownPickValue" title="Included: Status: Inactive" onmousedown="picklistSetup.handleClick(event,this)" ondblclick="picklistSetup.handleDblClick(event,this)" onmousemove="picklistSetup.handleMouseMove(event,this)">&nbsp;Bankrupt&nbsp;</td></tr><tr><td id="te_r2c0" class="hiddenPickValue" title="Excluded: Status: Prospect" onmousedown="picklistSetup.handleClick(event,this)" ondblclick="picklistSetup.handleDblClick(event,this)" onmousemove="picklistSetup.handleMouseMove(event,this)">&nbsp;Risk Unacceptable&nbsp;</td><td id="te_r2c1" class="hiddenPickValue" title="Excluded: Status: Onboarding" onmousedown="picklistSetup.handleClick(event,this)" ondblclick="picklistSetup.handleDblClick(event,this)" onmousemove="picklistSetup.handleMouseMove(event,this)">&nbsp;Risk Unacceptable&nbsp;</td><td id="te_r2c2" class="hiddenPickValue" title="Excluded: Status: Client" onmousedown="picklistSetup.handleClick(event,this)" ondblclick="picklistSetup.handleDblClick(event,this)" onmousemove="picklistSetup.handleMouseMove(event,this)">&nbsp;Risk Unacceptable&nbsp;</td><td id="te_r2c3" class="hiddenPickValue" title="Excluded: Status: Active" onmousedown="picklistSetup.handleClick(event,this)" ondblclick="picklistSetup.handleDblClick(event,this)" onmousemove="picklistSetup.handleMouseMove(event,this)">&nbsp;Risk Unacceptable&nbsp;</td><td id="te_r2c4" class="hiddenPickValue" title="Excluded: Status: Inactive" onmousedown="picklistSetup.handleClick(event,this)" ondblclick="picklistSetup.handleDblClick(event,this)" onmousemove="picklistSetup.handleMouseMove(event,this)">&nbsp;Risk Unacceptable&nbsp;</td></tr><tr><td id="te_r3c0" class="hiddenPickValue" title="Excluded: Status: Prospect" onmousedown="picklistSetup.handleClick(event,this)" ondblclick="picklistSetup.handleDblClick(event,this)" onmousemove="picklistSetup.handleMouseMove(event,this)">&nbsp;Departed to Competitor&nbsp;</td><td id="te_r3c1" class="hiddenPickValue" title="Excluded: Status: Onboarding" onmousedown="picklistSetup.handleClick(event,this)" ondblclick="picklistSetup.handleDblClick(event,this)" onmousemove="picklistSetup.handleMouseMove(event,this)">&nbsp;Departed to Competitor&nbsp;</td><td id="te_r3c2" class="hiddenPickValue" title="Excluded: Status: Client" onmousedown="picklistSetup.handleClick(event,this)" ondblclick="picklistSetup.handleDblClick(event,this)" onmousemove="picklistSetup.handleMouseMove(event,this)">&nbsp;Departed to Competitor&nbsp;</td><td id="te_r3c3" class="hiddenPickValue" title="Excluded: Status: Active" onmousedown="picklistSetup.handleClick(event,this)" ondblclick="picklistSetup.handleDblClick(event,this)" onmousemove="picklistSetup.handleMouseMove(event,this)">&nbsp;Departed to Competitor&nbsp;</td><td id="te_r3c4" class="shownPickValue" title="Included: Status: Inactive" onmousedown="picklistSetup.handleClick(event,this)" ondblclick="picklistSetup.handleDblClick(event,this)" onmousemove="picklistSetup.handleMouseMove(event,this)">&nbsp;Departed to Competitor&nbsp;</td></tr><tr><td id="te_r4c0" class="hiddenPickValue" title="Excluded: Status: Prospect" onmousedown="picklistSetup.handleClick(event,this)" ondblclick="picklistSetup.handleDblClick(event,this)" onmousemove="picklistSetup.handleMouseMove(event,this)">&nbsp;Merger&nbsp;</td><td id="te_r4c1" class="hiddenPickValue" title="Excluded: Status: Onboarding" onmousedown="picklistSetup.handleClick(event,this)" ondblclick="picklistSetup.handleDblClick(event,this)" onmousemove="picklistSetup.handleMouseMove(event,this)">&nbsp;Merger&nbsp;</td><td id="te_r4c2" class="hiddenPickValue" title="Excluded: Status: Client" onmousedown="picklistSetup.handleClick(event,this)" ondblclick="picklistSetup.handleDblClick(event,this)" onmousemove="picklistSetup.handleMouseMove(event,this)">&nbsp;Merger&nbsp;</td><td id="te_r4c3" class="hiddenPickValue" title="Excluded: Status: Active" onmousedown="picklistSetup.handleClick(event,this)" ondblclick="picklistSetup.handleDblClick(event,this)" onmousemove="picklistSetup.handleMouseMove(event,this)">&nbsp;Merger&nbsp;</td><td id="te_r4c4" class="shownPickValue" title="Included: Status: Inactive" onmousedown="picklistSetup.handleClick(event,this)" ondblclick="picklistSetup.handleDblClick(event,this)" onmousemove="picklistSetup.handleMouseMove(event,this)">&nbsp;Merger&nbsp;</td></tr><tr><td id="te_r5c0" class="hiddenPickValue" title="Excluded: Status: Prospect" onmousedown="picklistSetup.handleClick(event,this)" ondblclick="picklistSetup.handleDblClick(event,this)" onmousemove="picklistSetup.handleMouseMove(event,this)">&nbsp;No Products and Services&nbsp;</td><td id="te_r5c1" class="hiddenPickValue" title="Excluded: Status: Onboarding" onmousedown="picklistSetup.handleClick(event,this)" ondblclick="picklistSetup.handleDblClick(event,this)" onmousemove="picklistSetup.handleMouseMove(event,this)">&nbsp;No Products and Services&nbsp;</td><td id="te_r5c2" class="hiddenPickValue" title="Excluded: Status: Client" onmousedown="picklistSetup.handleClick(event,this)" ondblclick="picklistSetup.handleDblClick(event,this)" onmousemove="picklistSetup.handleMouseMove(event,this)">&nbsp;No Products and Services&nbsp;</td><td id="te_r5c3" class="hiddenPickValue" title="Excluded: Status: Active" onmousedown="picklistSetup.handleClick(event,this)" ondblclick="picklistSetup.handleDblClick(event,this)" onmousemove="picklistSetup.handleMouseMove(event,this)">&nbsp;No Products and Services&nbsp;</td><td id="te_r5c4" class="shownPickValue" title="Included: Status: Inactive" onmousedown="picklistSetup.handleClick(event,this)" ondblclick="picklistSetup.handleDblClick(event,this)" onmousemove="picklistSetup.handleMouseMove(event,this)">&nbsp;No Products and Services&nbsp;</td></tr><tr><td id="te_r6c0" class="hiddenPickValue" title="Excluded: Status: Prospect" onmousedown="picklistSetup.handleClick(event,this)" ondblclick="picklistSetup.handleDblClick(event,this)" onmousemove="picklistSetup.handleMouseMove(event,this)">&nbsp;No Statutory Market Account &nbsp;</td><td id="te_r6c1" class="hiddenPickValue" title="Excluded: Status: Onboarding" onmousedown="picklistSetup.handleClick(event,this)" ondblclick="picklistSetup.handleDblClick(event,this)" onmousemove="picklistSetup.handleMouseMove(event,this)">&nbsp;No Statutory Market Account &nbsp;</td><td id="te_r6c2" class="hiddenPickValue" title="Excluded: Status: Client" onmousedown="picklistSetup.handleClick(event,this)" ondblclick="picklistSetup.handleDblClick(event,this)" onmousemove="picklistSetup.handleMouseMove(event,this)">&nbsp;No Statutory Market Account &nbsp;</td><td id="te_r6c3" class="hiddenPickValue" title="Excluded: Status: Active" onmousedown="picklistSetup.handleClick(event,this)" ondblclick="picklistSetup.handleDblClick(event,this)" onmousemove="picklistSetup.handleMouseMove(event,this)">&nbsp;No Statutory Market Account &nbsp;</td><td id="te_r6c4" class="hiddenPickValue" title="Excluded: Status: Inactive" onmousedown="picklistSetup.handleClick(event,this)" ondblclick="picklistSetup.handleDblClick(event,this)" onmousemove="picklistSetup.handleMouseMove(event,this)">&nbsp;No Statutory Market Account &nbsp;</td></tr><tr><td id="te_r7c0" class="hiddenPickValue" title="Excluded: Status: Prospect" onmousedown="picklistSetup.handleClick(event,this)" ondblclick="picklistSetup.handleDblClick(event,this)" onmousemove="picklistSetup.handleMouseMove(event,this)">&nbsp;Other&nbsp;</td><td id="te_r7c1" class="hiddenPickValue" title="Excluded: Status: Onboarding" onmousedown="picklistSetup.handleClick(event,this)" ondblclick="picklistSetup.handleDblClick(event,this)" onmousemove="picklistSetup.handleMouseMove(event,this)">&nbsp;Other&nbsp;</td><td id="te_r7c2" class="hiddenPickValue" title="Excluded: Status: Client" onmousedown="picklistSetup.handleClick(event,this)" ondblclick="picklistSetup.handleDblClick(event,this)" onmousemove="picklistSetup.handleMouseMove(event,this)">&nbsp;Other&nbsp;</td><td id="te_r7c3" class="hiddenPickValue" title="Excluded: Status: Active" onmousedown="picklistSetup.handleClick(event,this)" ondblclick="picklistSetup.handleDblClick(event,this)" onmousemove="picklistSetup.handleMouseMove(event,this)">&nbsp;Other&nbsp;</td><td id="te_r7c4" class="shownPickValue" title="Included: Status: Inactive" onmousedown="picklistSetup.handleClick(event,this)" ondblclick="picklistSetup.handleDblClick(event,this)" onmousemove="picklistSetup.handleMouseMove(event,this)">&nbsp;Other&nbsp;</td></tr><tr><td id="te_r8c0" class="hiddenPickValue" title="Excluded: Status: Prospect" onmousedown="picklistSetup.handleClick(event,this)" ondblclick="picklistSetup.handleDblClick(event,this)" onmousemove="picklistSetup.handleMouseMove(event,this)">&nbsp;Project Cancelled&nbsp;</td><td id="te_r8c1" class="hiddenPickValue" title="Excluded: Status: Onboarding" onmousedown="picklistSetup.handleClick(event,this)" ondblclick="picklistSetup.handleDblClick(event,this)" onmousemove="picklistSetup.handleMouseMove(event,this)">&nbsp;Project Cancelled&nbsp;</td><td id="te_r8c2" class="hiddenPickValue" title="Excluded: Status: Client" onmousedown="picklistSetup.handleClick(event,this)" ondblclick="picklistSetup.handleDblClick(event,this)" onmousemove="picklistSetup.handleMouseMove(event,this)">&nbsp;Project Cancelled&nbsp;</td><td id="te_r8c3" class="hiddenPickValue" title="Excluded: Status: Active" onmousedown="picklistSetup.handleClick(event,this)" ondblclick="picklistSetup.handleDblClick(event,this)" onmousemove="picklistSetup.handleMouseMove(event,this)">&nbsp;Project Cancelled&nbsp;</td><td id="te_r8c4" class="hiddenPickValue" title="Excluded: Status: Inactive" onmousedown="picklistSetup.handleClick(event,this)" ondblclick="picklistSetup.handleDblClick(event,this)" onmousemove="picklistSetup.handleMouseMove(event,this)">&nbsp;Project Cancelled&nbsp;</td></tr><tr><td id="te_r9c0" class="hiddenPickValue" title="Excluded: Status: Prospect" onmousedown="picklistSetup.handleClick(event,this)" ondblclick="picklistSetup.handleDblClick(event,this)" onmousemove="picklistSetup.handleMouseMove(event,this)">&nbsp;Proposal Declined (Credit Commission)&nbsp;</td><td id="te_r9c1" class="hiddenPickValue" title="Excluded: Status: Onboarding" onmousedown="picklistSetup.handleClick(event,this)" ondblclick="picklistSetup.handleDblClick(event,this)" onmousemove="picklistSetup.handleMouseMove(event,this)">&nbsp;Proposal Declined (Credit Commission)&nbsp;</td><td id="te_r9c2" class="hiddenPickValue" title="Excluded: Status: Client" onmousedown="picklistSetup.handleClick(event,this)" ondblclick="picklistSetup.handleDblClick(event,this)" onmousemove="picklistSetup.handleMouseMove(event,this)">&nbsp;Proposal Declined (Credit Commission)&nbsp;</td><td id="te_r9c3" class="hiddenPickValue" title="Excluded: Status: Active" onmousedown="picklistSetup.handleClick(event,this)" ondblclick="picklistSetup.handleDblClick(event,this)" onmousemove="picklistSetup.handleMouseMove(event,this)">&nbsp;Proposal Declined (Credit Commission)&nbsp;</td><td id="te_r9c4" class="hiddenPickValue" title="Excluded: Status: Inactive" onmousedown="picklistSetup.handleClick(event,this)" ondblclick="picklistSetup.handleDblClick(event,this)" onmousemove="picklistSetup.handleMouseMove(event,this)">&nbsp;Proposal Declined (Credit Commission)&nbsp;</td></tr></tbody></table></div>

Yes, except your provided HTML is in one big lump with no newlines -- that might be why your "For Each... line on the System Clipboard" is failing.

But (unless I'm missing something) I think you are overcomplicating things. It looks like you just need two simple "Search and Replace" actions, one to add the line break as a <br> (since we're working with HTML) which I'm not sure you even need, and one to replace title="Included: with style="color:yellow;" title="Included: (the p tag isn't necessary, you can style the cell contents directly).

Wrangle HTML.kmmacros (1.8 KB)

Image

1 Like

@Nige_S

This is a copy of a table block from a site so that's the reason why it's HTML.
You're correct that I have complicated the macro, don't know why I've gone this way :thinking: and didn't think of your solution.... Thanks a lot!!

1 Like