How to make word that is not in dictionary to be UNDERLINED?

London12F

Board Regular
Joined
Jun 21, 2016
Messages
59
The following VBA can change word that is not in dictionary to RED:



Code:
[COLOR=#333333]Sub zz()
[/COLOR]<code style="margin: 0px; padding: 0px; font-style: inherit; font-weight: inherit; line-height: 12px;">Dim ws As Worksheet, rng As Range, s$, w$
Set ws = ActiveSheet
    For Each rng In ws.UsedRange
        If rng.HasFormula Then GoSub Nextrng:
        If Application.CheckSpelling(rng.Value) Then GoTo Nextrng:
        s = " " & rng.Value
        i = 2
        While i < Len(s)
            If Mid(s, i - 1, 1) = " " And Mid(s, i, 1) <> "" Then
                j = InStr(i, s, " ") - 1
                If j = -1 Then j = Len(s)
                w = Mid(s, i, j - i + 1)
                If Not Application.CheckSpelling(w) Then
                    rng.Characters(Start:=i - 1, Length:=j - i + 1).Font.Color = vbRed
                End If
                i = j + 1
            End If
            i = i + 1
        Wend
Nextrng:
    Next rng 
</code>[COLOR=#333333]End Sub[/COLOR]


How to revise so that the word that is not in dictionary to be UNDERLINED?

<tbody>
</tbody>
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.

Marcelo Branco

MrExcel MVP
Joined
Aug 23, 2010
Messages
16,526
Office Version
  1. 2019
  2. 2010
Platform
  1. Windows
Try

Code:
rng.Font.Underline = xlUnderlineStyleSingle

M.
 

Marcelo Branco

MrExcel MVP
Joined
Aug 23, 2010
Messages
16,526
Office Version
  1. 2019
  2. 2010
Platform
  1. Windows
oops...correction

Code:
rng.Characters(Start:=i - 1, Length:=j - i + 1).Font.Underline = xlUnderlineStyleSingle

M.
 

Marcelo Branco

MrExcel MVP
Joined
Aug 23, 2010
Messages
16,526
Office Version
  1. 2019
  2. 2010
Platform
  1. Windows

ADVERTISEMENT

You are welcome. Thanks for the feedback.

M.
 

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
36,729
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
@London12F

You've been told before about cross-posting. Kindly comply with the rules in future or your posting privileges may be revoked. Thank you.
 

London12F

Board Regular
Joined
Jun 21, 2016
Messages
59

ADVERTISEMENT

RoryA ,
Sorry for cross-posting.
 

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
36,729
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
Cross posting is not a problem, but you must provide links to your cross posts please.
 

Watch MrExcel Video

Forum statistics

Threads
1,130,048
Messages
5,639,769
Members
417,111
Latest member
buyukbang

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top