View Single Post
 
Old 10-13-2016, 11:34 PM
Pankaj Pankaj is offline Windows 7 64bit Office 2016
Novice
 
Join Date: Oct 2016
Posts: 1
Pankaj is on a distinguished road
Default VBA word macro to highlight a selected text just like a spell checker

I used the below code to count the no. of words in sentences. If no. of words is greater than 20 then it should highlight it. I used the below code. It's just coloring the background. I want to just highlight it just like spell checker. please help.

Code:

Sub Count_of_words()
'
' Count Macro
'
'

Dim s As Range
For Each s In Selection.Sentences
If s.Words.count > 20 Then s.HighlightColorIndex = wdYellow


Next

End Sub
Reply With Quote