Sub spellList()
Dim c As Range
Dim myWord As String
Dim i As Long, x As Long
Dim myCell As String
Dim textCells As Range
Dim splitWords
Set textCells = Union(ActiveSheet.Cells.SpecialCells(xlCellTypeConstants, xlTextValues), _
ActiveSheet.Cells.SpecialCells(xlCellTypeFormulas, xlTextValues))
i = 1
Application.ScreenUpdating = False
'Check all the constants
For Each c In textCells
myCell = c.Address
splitWords = Split(c.Value, " ")
For x = 0 To UBound(splitWords)
myWord = splitWords(x)
If Not (Application.CheckSpelling(myWord)) Then
Worksheets("Output").Cells(i, "A").Value = myWord
Worksheets("Output").Cells(i, "B").Value = myCell
i = i + 1
End If
Next x
Next c
Application.ScreenUpdating = True
End Sub
Sub spellList()
Dim c As Range
Dim myWord As String
Dim i As Long, x As Long
Dim myCell As String
Dim textCells As Range, textCells1 As Range, check_range As Range
Dim splitWords
On Error Resume Next
Set textCells = ActiveSheet.Cells.SpecialCells(xlCellTypeConstants, xlTextValues)
Set textCells1 = ActiveSheet.Cells.SpecialCells(xlCellTypeFormulas, xlTextValues)
On Error GoTo 0
If Not (textCells Is Nothing) Then
Set check_range = textCells
End If
If Not (textCells1 Is Nothing) Then
Set check_range = Union(check_range, textCells1)
End If
i = 1
Application.ScreenUpdating = False
'Check all the constants
For Each c In check_range
myCell = c.Address
splitWords = Split(c.Value, " ")
For x = 0 To UBound(splitWords)
myWord = splitWords(x)
If Not (Application.CheckSpelling(myWord)) Then
Worksheets("Output").Cells(i, "A").Value = myWord
Worksheets("Output").Cells(i, "B").Value = myCell
i = i + 1
End If
Next x
Next c
Application.ScreenUpdating = True
End Sub
Sub spellList()
Dim c As Range
Dim myWord As String
Dim i As Long, x As Long
Dim myCell As String
Dim textCells As Range, textCells1 As Range, check_range As Range
Dim splitWords
'Use the Special Cells group to look for text string in constants and in formulas
'XL throws an error if no cells exist within one of these groups, hence
'the On error resume Next comment
'Purpose is to limit our scope to just cells with text. This is better than searching
'every cell as it will be much faster
On Error Resume Next
Set textCells = ActiveSheet.Cells.SpecialCells(xlCellTypeConstants, xlTextValues)
Set textCells1 = ActiveSheet.Cells.SpecialCells(xlCellTypeFormulas, xlTextValues)
On Error GoTo 0
'Check each group to make sure something exists
If Not (textCells Is Nothing) Then
Set check_range = textCells
End If
If Not (textCells1 Is Nothing) Then
Set check_range = Union(check_range, textCells1)
End If
'I added the next line in case there were no text strings anywhere in sheet
If check_range Is Nothing Then Exit Sub
i = 1
Application.ScreenUpdating = False
'Check all the constants
'First, we're going to look at each cell within our check_range
For Each c In check_range
'Store the cell address for later use
myCell = c.Address
'Split the contents of the cell into the splitWords array.
'We split at every space
splitWords = Split(c.Value, " ")
'Now, loops through every word within our array
For x = 0 To UBound(splitWords)
'Store the word for later use
myWord = splitWords(x)
'This is the "spell checker" for VB. It has a few other options
'you can read about in help file, but basically you give it
'a word and it returns True/False if the word is spelled correct
If Not (Application.CheckSpelling(myWord)) Then
'If it wasn't spelled correct, add them to our list
Worksheets("Output").Cells(i, "A").Value = myWord
Worksheets("Output").Cells(i, "B").Value = myCell
'Increment our output counter so the next word will
'be written to next row
i = i + 1
End If
Next x
Next c
Application.ScreenUpdating = True
End Sub
Option Explicit
Sub spellList()
Const kbOnlyOnce = True
Dim bShouldAdd As Boolean
Dim c As Range, c1 As Range
Dim myWord As String
Dim i As Long, x As Long
Dim myCell As String
Dim textCells As Range, textCells1 As Range, check_range As Range
Dim splitWords
'Use the Special Cells group to look for text string in constants and in formulas
'XL throws an error if no cells exist within one of these groups, hence
'the On error resume Next comment
'Purpose is to limit our scope to just cells with text. This is better than searching
'every cell as it will be much faster
On Error Resume Next
Set textCells = ActiveSheet.Cells.SpecialCells(xlCellTypeConstants, xlTextValues)
Set textCells1 = ActiveSheet.Cells.SpecialCells(xlCellTypeFormulas, xlTextValues)
On Error GoTo 0
'Check each group to make sure something exists
If Not (textCells Is Nothing) Then
Set check_range = textCells
End If
If Not (textCells1 Is Nothing) Then
Set check_range = Union(check_range, textCells1)
End If
'I added the next line in case there were no text strings anywhere in sheet
If check_range Is Nothing Then Exit Sub
i = 1
Application.ScreenUpdating = False
'Check all the constants
'First, we're going to look at each cell within our check_range
For Each c In check_range
'Store the cell address for later use
myCell = c.Address
'Split the contents of the cell into the splitWords array.
'We split at every space
splitWords = Split(c.Value, " ")
'Now, loops through every word within our array
For x = 0 To UBound(splitWords)
'Store the word for later use
myWord = splitWords(x)
'This is the "spell checker" for VB. It has a few other options
'you can read about in help file, but basically you give it
'a word and it returns True/False if the word is spelled correct
If Not (Application.CheckSpelling(myWord)) Then
' If it should appear only once then check if previously exists
' otherwise add it always
If kbOnlyOnce Then
Set c1 = Worksheets("Output").Columns("A").Find( _
myWord, Worksheets("Output").Cells(1, "A"), xlValues, xlWhole)
bShouldAdd = c1 Is Nothing
Else
bShouldAdd = True
End If
' Check if should be added
If bShouldAdd Then
'If it wasn't spelled correct, add them to our list
Worksheets("Output").Cells(i, "A").Value = myWord
Worksheets("Output").Cells(i, "B").Value = myCell
'Increment our output counter so the next word will
'be written to next row
i = i + 1
End If
End If
Next x
Next c
Application.ScreenUpdating = True
End Sub