I am trying to create a Excel VBA Macro to find bold text within cells with non bold text and add html bold tags around the original bold text and leave the non bold text alone. Example:
Find:
"This bold word"
and
Replace with:
"This <code style="margin: 0px; padding: 1px 5px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; font-size: 13px; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; vertical-align: baseline; background-color: rgb(239, 240, 241); white-space: pre-wrap;"><b>bold</b></code> word" (both html tags and word need to be bold)
It is very important to note the the bold text is within cells with non bold text and only the bold text should be replaced with bold and html tags. All Cell font must be kept.
I will also need a macro to convert the other way as well. Meaning find bold tags (<code style="margin: 0px; padding: 1px 5px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; font-size: 13px; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; vertical-align: baseline; background-color: rgb(239, 240, 241); white-space: pre-wrap;"><b></b></code>) with or without bold font itself and remove the tags and ensure the text is bold.
I don't even care if it is a find/replace or if it is found in one document and created in a new document or sheet with the modification.
Closest VBA I could find online to achieve this:
https://www.mrexcel.com/forum/excel...replace-loses-text-properties-formatting.html
[word] Find.execute On Individual Basis
but not what I need.
Please help.
Find:
"This bold word"
and
Replace with:
"This <code style="margin: 0px; padding: 1px 5px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; font-size: 13px; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; vertical-align: baseline; background-color: rgb(239, 240, 241); white-space: pre-wrap;"><b>bold</b></code> word" (both html tags and word need to be bold)
It is very important to note the the bold text is within cells with non bold text and only the bold text should be replaced with bold and html tags. All Cell font must be kept.
I will also need a macro to convert the other way as well. Meaning find bold tags (<code style="margin: 0px; padding: 1px 5px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; font-size: 13px; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; vertical-align: baseline; background-color: rgb(239, 240, 241); white-space: pre-wrap;"><b></b></code>) with or without bold font itself and remove the tags and ensure the text is bold.
I don't even care if it is a find/replace or if it is found in one document and created in a new document or sheet with the modification.
Closest VBA I could find online to achieve this:
https://www.mrexcel.com/forum/excel...replace-loses-text-properties-formatting.html
[word] Find.execute On Individual Basis
but not what I need.
Please help.