Friday, October 18, 2019

Spell Check functionality using Macro

Hi folks

In excel file many times people enter wrong data on some template and need to check the spell. We can add macro button and add the below code.

can do that by adding Macro button on it and add the below code.

Sub SpellCheck_Click()
    
    Dim WorkRange As Range
    Dim FoundCells As Range
    Dim cell As Range
    Set WorkRange = ActiveSheet.UsedRange
    For Each cell In WorkRange
        If cell.Locked = False Then
            If FoundCells Is Nothing Then
                Set FoundCells = cell
            Else
                Set FoundCells = Union(FoundCells, cell)
            End If
        End If
    Next cell
    If FoundCells Is Nothing Then
        MsgBox "All cells are locked."
    Else
        FoundCells.CheckSpellingCustomDictionary:="CUSTOM.DIC", _
IgnoreUppercase:=False, AlwaysSuggest:=True, SpellLang:=3081
    End If
    

End Sub


No comments:

Post a Comment