<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: HTML in Cells</title>
	<atom:link href="http://www.dailydoseofexcel.com/archives/2004/11/29/html-in-cells/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dailydoseofexcel.com/archives/2004/11/29/html-in-cells/</link>
	<description>Daily posts of Excel tips…and other stuff</description>
	<lastBuildDate>Wed, 08 Feb 2012 12:03:16 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Coca IQ Bogdan</title>
		<link>http://www.dailydoseofexcel.com/archives/2004/11/29/html-in-cells/#comment-2705</link>
		<dc:creator>Coca IQ Bogdan</dc:creator>
		<pubDate>Wed, 01 Dec 2004 12:34:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=884#comment-2705</guid>
		<description>&lt;p&gt;Thx again for you wonderfull post, I never knew that Excel can support HTML at all , are those tables from Microsoft Words like the Excel ones? May I also do the same out there? How?&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Thx again for you wonderfull post, I never knew that Excel can support HTML at all , are those tables from Microsoft Words like the Excel ones? May I also do the same out there? How?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter Grebenik</title>
		<link>http://www.dailydoseofexcel.com/archives/2004/11/29/html-in-cells/#comment-2701</link>
		<dc:creator>Peter Grebenik</dc:creator>
		<pubDate>Wed, 01 Dec 2004 10:25:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=884#comment-2701</guid>
		<description>&lt;p&gt;As a chemist I have to deal with a lot of sub- and super scripting. Here is some code (which could certainly be improved upon) which I wrote to automatically subscript and superscript a string according to the normal uses of a chemist i.e. H2O should appear as H&lt;sub&gt;2&lt;/sub&gt;O and Ca+2 should appear as Ca&lt;sup&gt;+2&lt;/sup&gt;. The code also allows for overriding the automated character changing by bracketing superscripted sections with the character &quot;^&quot;, subscripted sections with the character &quot;~&quot; and plain sections with the character &quot;¬&quot; (note that these control characters are lost once the macro has been run).&lt;/p&gt;
&lt;p&gt;
&lt;pre&gt;Sub AutoSuperAndSub(cref)

    Dim SupB(20) As Integer, SupE(20) As Integer, SubB(20) As Integer, SubE(20) As Integer
    Dim PPos As Integer, n As Integer, Nsup As Integer, Nsub As Integer
    Dim Dat As String, Char As String, NChar As String
    Dim PCh As Boolean, Num As Boolean, Ch As Boolean, PlMi As Boolean
    Dim EventStat As Boolean

    NChar = &quot;abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ)]&quot;
    PPos = 0
    PCh = False
    n = 1
    Nsup = 0
    Nsub = 0

    Dat = Range(cref).Value
    Do
        Char = Mid(Dat, n, 1)
        Num = IsNumeric(Char)
        If InStr(&quot;+-&quot;, Char) &gt; 0 Then PlMi = True Else PlMi = False
        If InStr(NChar, Char) &gt; 0 Then Ch = True Else Ch = False

        &#039;manual setting of sub and super scripting
        If Char = &quot;^&quot; Then &#039;superscript next characters

            Dat = Left(Dat, n - 1) &amp; Mid(Dat, n + 1, 9999)
            Nsup = Nsup + 1
            SupB(Nsup) = n
            n = InStr(Dat, Char)
            Dat = Left(Dat, n - 1) &amp; Mid(Dat, n + 1, 9999)
            SupE(Nsup) = n
            PPos = 0

        ElseIf Char = &quot;~&quot; Then &#039;subscript next characters

            Dat = Left(Dat, n - 1) &amp; Mid(Dat, n + 1, 9999)
            Nsub = Nsub + 1
            SubB(Nsub) = n
            n = InStr(Dat, Char)
            Dat = Left(Dat, n - 1) &amp; Mid(Dat, n + 1, 9999)
            SubE(Nsub) = n
            PPos = 0

        ElseIf Char = &quot;¬&quot; Then &#039;characters unchanged

            Dat = Left(Dat, n - 1) &amp; Mid(Dat, n + 1, 9999)
            If PPos = -1 Then SubE(Nsub) = n
            If PPos = 1 Then SupE(Nsup) = n
            n = InStr(Dat, Char)
            Dat = Left(Dat, n - 1) &amp; Mid(Dat, n + 1, 9999)
            PPos = 0

        &#039;now automatic setting of sub and super scripts
        ElseIf PPos = 0 Then

            If Ch Then
            ElseIf (PCh And Num) Then
                Nsub = Nsub + 1
                SubB(Nsub) = n
                PPos = -1
            ElseIf (PCh And PlMi And IsNumeric(Mid(Dat, n + 1, 1))) Then
                Nsup = Nsup + 1
                SupB(Nsup) = n
                PPos = 1
            End If

        ElseIf PPos = -1 Then

            If Num Then
            ElseIf PlMi Then
                SubE(Nsub) = n
                Nsup = Nsup + 1
                SupB(Nsup) = n
                PPos = 1
            Else
                SubE(Nsub) = n
                PPos = 0
            End If

        ElseIf PPos = 1 Then

            If Num Then
            Else
                SupE(Nsup) = n
                PPos = 0
            End If

        End If

        PCh = Ch

        n = n + 1

    Loop Until n &gt; Len(Dat)
    EventStat = Application.EnableEvents
    Application.EnableEvents = False
    Range(cref) = Dat
    For n = 1 To Nsup
        Range(cref).Characters(Start:=SupB(n), Length:=SupE(n) - SupB(n)).Font.Superscript = True
    Next

    For n = 1 To Nsub
        Range(cref).Characters(Start:=SubB(n), Length:=SubE(n) - SubB(n)).Font.Subscript = True
    Next
    Application.EnableEvents = EventStat

End Sub
&lt;/pre&gt;
&lt;p&gt;&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>As a chemist I have to deal with a lot of sub- and super scripting. Here is some code (which could certainly be improved upon) which I wrote to automatically subscript and superscript a string according to the normal uses of a chemist i.e. H2O should appear as H<sub>2</sub>O and Ca+2 should appear as Ca<sup>+2</sup>. The code also allows for overriding the automated character changing by bracketing superscripted sections with the character &#8220;^&#8221;, subscripted sections with the character &#8220;~&#8221; and plain sections with the character &#8220;¬&#8221; (note that these control characters are lost once the macro has been run).</p>
<p><pre>Sub AutoSuperAndSub(cref)

    Dim SupB(20) As Integer, SupE(20) As Integer, SubB(20) As Integer, SubE(20) As Integer
    Dim PPos As Integer, n As Integer, Nsup As Integer, Nsub As Integer
    Dim Dat As String, Char As String, NChar As String
    Dim PCh As Boolean, Num As Boolean, Ch As Boolean, PlMi As Boolean
    Dim EventStat As Boolean

    NChar = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ)]"
    PPos = 0
    PCh = False
    n = 1
    Nsup = 0
    Nsub = 0

    Dat = Range(cref).Value
    Do
        Char = Mid(Dat, n, 1)
        Num = IsNumeric(Char)
        If InStr("+-", Char) &gt; 0 Then PlMi = True Else PlMi = False
        If InStr(NChar, Char) &gt; 0 Then Ch = True Else Ch = False

        'manual setting of sub and super scripting
        If Char = "^" Then 'superscript next characters

            Dat = Left(Dat, n - 1) &amp; Mid(Dat, n + 1, 9999)
            Nsup = Nsup + 1
            SupB(Nsup) = n
            n = InStr(Dat, Char)
            Dat = Left(Dat, n - 1) &amp; Mid(Dat, n + 1, 9999)
            SupE(Nsup) = n
            PPos = 0

        ElseIf Char = "~" Then 'subscript next characters

            Dat = Left(Dat, n - 1) &amp; Mid(Dat, n + 1, 9999)
            Nsub = Nsub + 1
            SubB(Nsub) = n
            n = InStr(Dat, Char)
            Dat = Left(Dat, n - 1) &amp; Mid(Dat, n + 1, 9999)
            SubE(Nsub) = n
            PPos = 0

        ElseIf Char = "¬" Then 'characters unchanged

            Dat = Left(Dat, n - 1) &amp; Mid(Dat, n + 1, 9999)
            If PPos = -1 Then SubE(Nsub) = n
            If PPos = 1 Then SupE(Nsup) = n
            n = InStr(Dat, Char)
            Dat = Left(Dat, n - 1) &amp; Mid(Dat, n + 1, 9999)
            PPos = 0

        'now automatic setting of sub and super scripts
        ElseIf PPos = 0 Then

            If Ch Then
            ElseIf (PCh And Num) Then
                Nsub = Nsub + 1
                SubB(Nsub) = n
                PPos = -1
            ElseIf (PCh And PlMi And IsNumeric(Mid(Dat, n + 1, 1))) Then
                Nsup = Nsup + 1
                SupB(Nsup) = n
                PPos = 1
            End If

        ElseIf PPos = -1 Then

            If Num Then
            ElseIf PlMi Then
                SubE(Nsub) = n
                Nsup = Nsup + 1
                SupB(Nsup) = n
                PPos = 1
            Else
                SubE(Nsub) = n
                PPos = 0
            End If

        ElseIf PPos = 1 Then

            If Num Then
            Else
                SupE(Nsup) = n
                PPos = 0
            End If

        End If

        PCh = Ch

        n = n + 1

    Loop Until n &gt; Len(Dat)
    EventStat = Application.EnableEvents
    Application.EnableEvents = False
    Range(cref) = Dat
    For n = 1 To Nsup
        Range(cref).Characters(Start:=SupB(n), Length:=SupE(n) - SupB(n)).Font.Superscript = True
    Next

    For n = 1 To Nsub
        Range(cref).Characters(Start:=SubB(n), Length:=SubE(n) - SubB(n)).Font.Subscript = True
    Next
    Application.EnableEvents = EventStat

End Sub
</pre></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rob van Gelder</title>
		<link>http://www.dailydoseofexcel.com/archives/2004/11/29/html-in-cells/#comment-2676</link>
		<dc:creator>Rob van Gelder</dc:creator>
		<pubDate>Tue, 30 Nov 2004 06:06:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=884#comment-2676</guid>
		<description>&lt;p&gt;Dick,&lt;/p&gt;
&lt;p&gt;I tried a few approaches. As I recall, it became difficult to write the text and format it at the same time.&lt;br&gt;
It seems as though formatting is stored per character, not between characters.&lt;/p&gt;
&lt;p&gt;The reverse would be great wouldn&#039;t it?&lt;br&gt;
Users able to format their cells and comments the way they want then store that away in a database for a later reload. If I get time I may well write something.&lt;/p&gt;
&lt;p&gt;Here&#039;s the change trigger:&lt;/p&gt;
&lt;p&gt;Const cHTMLCellID = &quot;&lt;xl&gt;&quot;&lt;/xl&gt;&lt;/p&gt;
&lt;p&gt;Private Sub Worksheet_Change(ByVal Target As Range)&lt;br&gt;
    Dim rng As Range, str As String&lt;/p&gt;
&lt;p&gt;    For Each rng In Target&lt;br&gt;
        If StrComp(Left(rng.Value, Len(cHTMLCellID)), cHTMLCellID, vbTextCompare) = 0 Then&lt;br&gt;
            WriteFormattedText rng, rng.Value&lt;br&gt;
        End If&lt;br&gt;
    Next&lt;br&gt;
End Sub&lt;/p&gt;
&lt;p&gt;I thought I would see what happens if I use html as the identifier.&lt;br&gt;
Excel takes over and applies it&#039;s own method. Something which totally surprised me.&lt;br&gt;
What Excel does with the string could well make my code redundant!&lt;/p&gt;
&lt;p&gt;It only seems to work on &quot;paste&quot; operation - I don&#039;t know how to activate the &quot;formatting&quot; without doing a paste - yet.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Dick,</p>
<p>I tried a few approaches. As I recall, it became difficult to write the text and format it at the same time.<br />
It seems as though formatting is stored per character, not between characters.</p>
<p>The reverse would be great wouldn&#8217;t it?<br />
Users able to format their cells and comments the way they want then store that away in a database for a later reload. If I get time I may well write something.</p>
<p>Here&#8217;s the change trigger:</p>
<p>Const cHTMLCellID = &#8220;<xl>&#8220;</xl></p>
<p>Private Sub Worksheet_Change(ByVal Target As Range)<br />
    Dim rng As Range, str As String</p>
<p>    For Each rng In Target<br />
        If StrComp(Left(rng.Value, Len(cHTMLCellID)), cHTMLCellID, vbTextCompare) = 0 Then<br />
            WriteFormattedText rng, rng.Value<br />
        End If<br />
    Next<br />
End Sub</p>
<p>I thought I would see what happens if I use html as the identifier.<br />
Excel takes over and applies it&#8217;s own method. Something which totally surprised me.<br />
What Excel does with the string could well make my code redundant!</p>
<p>It only seems to work on &#8220;paste&#8221; operation &#8211; I don&#8217;t know how to activate the &#8220;formatting&#8221; without doing a paste &#8211; yet.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dick</title>
		<link>http://www.dailydoseofexcel.com/archives/2004/11/29/html-in-cells/#comment-2674</link>
		<dc:creator>Dick</dc:creator>
		<pubDate>Tue, 30 Nov 2004 03:18:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=884#comment-2674</guid>
		<description>&lt;p&gt;Rob:  I though the add-in would be a pretty easy jump (you already did the hard work) but now I think you would need to able to do the reverse, that is, convert the cell back to markup so it can be easily edited.  Maybe a couple of rainy days.&lt;/p&gt;
&lt;p&gt;I thought you were nuts looping through the characters one-by-one and that there had to be an easier way.  So far, all the easier ways I&#039;ve thought of didn&#039;t turn out easier. What other approaches, if any, did you try for parsing out the tags?&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Rob:  I though the add-in would be a pretty easy jump (you already did the hard work) but now I think you would need to able to do the reverse, that is, convert the cell back to markup so it can be easily edited.  Maybe a couple of rainy days.</p>
<p>I thought you were nuts looping through the characters one-by-one and that there had to be an easier way.  So far, all the easier ways I&#8217;ve thought of didn&#8217;t turn out easier. What other approaches, if any, did you try for parsing out the tags?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rob van Gelder</title>
		<link>http://www.dailydoseofexcel.com/archives/2004/11/29/html-in-cells/#comment-2665</link>
		<dc:creator>Rob van Gelder</dc:creator>
		<pubDate>Tue, 30 Nov 2004 00:50:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=884#comment-2665</guid>
		<description>&lt;p&gt;Dick,&lt;/p&gt;
&lt;p&gt;Thanks for the support. Appreciate you mentioning it on your page.&lt;/p&gt;
&lt;p&gt;Hopefully it&#039;s of use to someone out there.&lt;/p&gt;
&lt;p&gt;Indeed, a good idea about creating an add-in. A rainy day perhaps :)&lt;/p&gt;
&lt;p&gt;Cheers&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Dick,</p>
<p>Thanks for the support. Appreciate you mentioning it on your page.</p>
<p>Hopefully it&#8217;s of use to someone out there.</p>
<p>Indeed, a good idea about creating an add-in. A rainy day perhaps <img src='http://www.dailydoseofexcel.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Cheers</p>
]]></content:encoded>
	</item>
</channel>
</rss>

