need expert suggestion

MUKESHY12390

Well-known Member
Joined
Sep 18, 2012
Messages
901
Office Version
  1. 2013
  2. 2011
  3. 2010
  4. 2007
Platform
  1. Windows
Here we go .. . I found this code on internet this works amazing ,Basically what it does mark all spelling error in particular cell.
Understood all line but not able to understand the part in red

I know it looks very mess on post but when you copy and paste it to visual basic editor it will be very clear to read.

if anybody able to give their advice what actually it does just part in red.


Code:
''Purpose: SpellChecks the entire sheet (or some other specified range) Cell-by-Cell and Word-by-Word,
' ' highlighting in a color those Words and those Cells with misspelled Words.
' ' This can run S-L-O-W since it is calling the SpellChecker for each individual Word.
'
' ' Optionally can set the Column number that you want the text MISSPELLED inserted into
' ' so that you can later sort the sheet on that Column to consolidate the problem Rows.
'
' ' Version 1.0.2, September 2009, Rick Powell
'Sub Check_spell_error()
'
' ' You can specify a Range by indicating the upper left and the lower right Cell.
' ' The default Range uses the entire used area of the Sheet.
' Dim oRange As Excel.Range
' 'Set oRange = Range("A1:D500")
' Set oRange = ActiveSheet.UsedRange
'
' Application.ScreenUpdating = True
'
' ' You can pick which Dictionary Language to spell check against.
' ' There are many, but the following are the most likely.
' 'Application.SpellingOptions.DictLang = msoLanguageIDEnglishUS ' value 1033
' Application.SpellingOptions.DictLang = msoLanguageIDEnglishUK ' value 2057
'
' ' Other possible spell check options.
' Application.SpellingOptions.SuggestMainOnly = True
' ' The following assumes you want the SpellChecker to ignore Uppercase things, like ACRONYMS.
' Application.SpellingOptions.IgnoreCaps = True
' Application.SpellingOptions.IgnoreMixedDigits = True
' Application.SpellingOptions.IgnoreFileNames = True
'
' ' For Cell Highlighting, there are 8 named colors you may choose from:
' ' vbBlack, vbWhite, vbRed, vbGreen, vbBlue, vbYellow, vbMagenta, vbCyan.
' Dim lCellHighlightColor As Long
' lCellHighlightColor = vbYellow
'
' ' For Word Highlighting, there are 8 named colors you may choose from:
' ' vbBlack, vbWhite, vbRed, vbGreen, vbBlue, vbYellow, vbMagenta, vbCyan.
' Dim lWordHighlightColor As Long
' lWordHighlightColor = vbRed
'
' ' You should set these next 3 items
' ' if you want to have one Column used to mark ANY Cell misspellings for the entire Row.
' Dim bColumnMarker As Boolean
' 'bColumnMarker = False
' bColumnMarker = True
'
' ' Column A = 1, Column B = 2, etc.
' Dim iColumnToMark As Integer
' iColumnToMark = 7
'
' Dim sMarkerText As String
' sMarkerText = "MISSPELLED"
'
' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' ' The values for the items above should be modified by the user, as necessary. '
' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
' On Error GoTo 0
'
' Dim oCell As Object
' Dim iLastRowProcessed As Integer
' iLastRowProcessed = 0
'
' For Each oCell In oRange
'
' If ((bColumnMarker = True) And _
' (iLastRowProcessed <> oCell.Row)) Then
' ' When beginning to process each new Row, clear out any previous MISSPELLED marker.
' iLastRowProcessed = oCell.Row
' Cells(oCell.Row, iColumnToMark) = ""
' End If
' Rows(oCell.Row).Select
'
' ' Boolean to track for ANY misspelling in the Cell.
' Dim bResultCell As Boolean
' bResultCell = True
'
' ' First spell check the entire cell (if less than 256 chars).
' ' This can catch some grammatical errors even if no spelling errors.
' If (Len(oCell.Text) < 256) Then
' bResultCell = Application.CheckSpelling(oCell.Text)
' End If
'
' Dim iTrackCharPos As Integer
' iTrackCharPos = 1
'
' ' Split the Text in the Cell into an array of words, using a Space as the delimiter.
' Dim vWords As Variant
' vWords = Split(oCell.Text, Chr(32), -1, vbBinaryCompare)
' Dim i As Integer
'
' ' Check the spelling of each word in the Cell.
' For i = LBound(vWords) To UBound(vWords)
'
' Dim iWordLen As Integer
' iWordLen = Len(vWords(i))
'
' Dim bResultWord As Boolean
' ' Note that a Word longer than 255 characters will generate Error 13.
' ' Any character string without any embedded space is considered a Word.
' bResultWord = Application.CheckSpelling(Word:=vWords(i))
'
' If (bResultWord = False) Then
' ' Thinks it is misspelled.
' ' Check for trailing punctuation and plural words like ACTION-EVENTs.
' ' The following is crude and should be made more robust when there is time.
' If (iWordLen > 1) Then
' Dim iWL As Integer
' For iWL = iWordLen To 1 Step -1
' If (Not (Mid(vWords(i), iWL, 1) Like "[0-9A-Za-z]")) Then
' vWords(i) = Left(vWords(i), (iWL - 1))
' Else
' Exit For
' End If
' Next iWL
' [COLOR="#FF0000"]If (Mid(vWords(i), iWL, 1) = "s") Then
' ' Last letter is lowercase "s".
' vWords(i) = Left(vWords(i), (iWL - 1))
' End If[/COLOR]' ' Retest.
' bResultWord = Application.CheckSpelling(Word:=vWords(i))
' End If
' End If
'
' If (bResultWord = True) Then
' ' If this is an Uppercased and Hyphenated word, we should split and lowercase then check each
''portion.
' If ((Len(vWords(i)) > 0) And (vWords(i) = UCase(vWords(i)))) Then
' ' Word is all Uppercase, check for hyphenation.
' Dim iHyphenPos As Integer
' iHyphenPos = InStr(1, vWords(i), "-")
' If (iHyphenPos > 0) Then
' ' Word is also hyphenated, split and lowercase then check each portion.
' Dim vHyphenates As Variant
' vHyphenates = Split(LCase(vWords(i)), "-", -1, vbBinaryCompare)
' Dim iH As Integer
' ' Check the spelling of each newly lowercased portion of the word.
' For iH = LBound(vHyphenates) To UBound(vHyphenates)
' bResultWord = Application.CheckSpelling(Word:=vHyphenates(iH))
' If (bResultWord = False) Then
' ' As soon as any portion is deemed misspelled, then done.
' Exit For
' End If
' Next iH
' End If
' End If
' End If
'
' If (bResultWord = False) Then
' bResultCell = False
' ' Highlight just this misspelled word in the Cell.
' oCell.Characters(iTrackCharPos, iWordLen).Font.Bold = True
' oCell.Characters(iTrackCharPos, iWordLen).Font.Color = lWordHighlightColor
' Else
' ' Clear any previous Highlight on just this word.
' oCell.Characters(iTrackCharPos, iWordLen).Font.Bold = False
' oCell.Characters(iTrackCharPos, iWordLen).Font.Color = vbBlack
' End If
'
' iTrackCharPos = iTrackCharPos + iWordLen + 1
'
' Next i
'
' If (bResultCell = True) Then
' ' The text contents of this Cell are NOT misspelled.
' ' Remove any previous highlighting by setting the Fill Color to the "No Fill" value.
' oCell.Interior.ColorIndex = xlColorIndexNone
' Else
' ' At least some of the text contents of this Cell are misspelled, so highlight the Cell.
' oCell.Interior.Color = lCellHighlightColor
' ' Mark the Row, if requested.
' If (bColumnMarker = True) Then
' Cells(oCell.Row, iColumnToMark) = sMarkerText
' End If
' End If
'
' Next oCell
'
'End Sub
 
Last edited:

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
My best guess is it is checking for plurals so ice and ices, place and places , mice and mices :) and removing the s
 
Upvote 0

Forum statistics

Threads
1,214,943
Messages
6,122,380
Members
449,080
Latest member
Armadillos

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
Back
Top