Need VBA code to do following
1. Unprotect active sheet with known password
2. Run spell check
3. Protect active sheet with known password while allowing row formatting in protected mode
Need VBA code to do following
1. Unprotect active sheet with known password
2. Run spell check
3. Protect active sheet with known password while allowing row formatting in protected mode
My Skill Level: Beginner
Where am I going wrong?
ActiveSheet.Unprotect Password:=“1234”
Cells.Checkspelling SpellLang:=1033
ActiveSheet.Protect Password:=“1234”, True, True
DrawingObjects:=True,
Contents:=True,
Scenarios:=True,
AllowFormattingRows:=True
Welcome to the Forum. I have added code tags for you please read the Forum Rules to understand why.
What is the error you are getting? CheckSpelling will display a list of errors.
This works for me
Sub SpellCheck()
Const PW As String = "1234"
ActiveSheet.Unprotect Password:=PW
UsedRange.Cells.CheckSpelling SpellLang:=1033
ActiveSheet.Protect Password:=PW, DrawingObjects:=True, _
Contents:=True, Scenarios:=True, AllowFormattingRows:=True
End Sub
This will spellcheck and change error text to red
Sub SpellCheckHighlight()
Dim rCl As Range
Const PW As String = "1234"
With ActiveSheet
.Unprotect Password:=PW
On Error GoTo exit_proc
For Each rCl In .UsedRange.SpecialCells(xlCellTypeConstants)
If Application.CheckSpelling(word:=rCl.Value) = False Then
rCl.Font.Color = vbRed
End If
Next
exit_proc:
.Protect Password:=PW, DrawingObjects:=True, _
Contents:=True, Scenarios:=True, AllowFormattingRows:=True
End With
End Sub
Display More
Don’t have an account yet? Register yourself now and be a part of our community!