title: Excel VBA to underline referenced cell data
body: <p>I have a string of text in cell A10, which begins with data from Sheet "Input," cell C2. I want the referenced data to be underlined. For example, if "John Smith" was in Input!C2, it should look like "John Smith is having trouble with this formula" with John Smith underlined. Below is the code I have, but it's not working -- it's underlining the entire string of text. Also, while I'm here, how can I get this to run automatically, rather than having to manually run the macro? Thanks in advance.</p>
  
  <pre><code>Sub Macro()
  
  With Range("A10")
      .Value = Range("Input!C2") &amp; " is having trouble with this formula"
      .Characters(1, Len(Range("Input!C2"))).Font.Underline = True
  End With
  
  End Sub
  </code></pre>