Click here to Skip to main content
15,897,519 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I want to underline the word, I have in a cell that is made up by merging other cells. I have no problem underlining words in single cells but not merged cells.
Any help?

What I have tried:

I have tried the following
VB
Public oSheet As Excel.Worksheet
Public oRng As Excel.Range
oRng = oSheet.Range("E" & x, "H" & x)
        oRng.MergeCells = True
        oRng.Value = "Count Back"
        oRng.Range("E" & x).Font.Underline = Excel.XlUnderlineStyle.xlUnderlineStyleSingle

and
VB
Public oSheet As Excel.Worksheet
Public oRng As Excel.Range
oRng = oSheet.Range("E" & x, "H" & x)
        oRng.MergeCells = True
        oRng.Value = "Count Back"
        oRng.Range("E" & x, "H" & x).Font.Underline = Excel.XlUnderlineStyle.xlUnderlineStyleSingle
Posted

1 solution

Your code is close. When you try to underline use the full reference, not just the E column part. This works:
VB
oSheet.Range("E" & x, "H" & x).Font.Underline = Excel.XlUnderlineStyle.xlUnderlineStyleSingle
 
Share this answer
 
Comments
Dave the Golfer 9-Feb-16 13:20pm    
Thanks very much. Works perfectly. Proper job.
ZurdoDev 9-Feb-16 13:21pm    
You're welcome. Glad to hear it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900