Forum

Use Spell Check on ...
 
Notifications
Clear all

Use Spell Check on protected worksheet using VBA Code

4 Posts
2 Users
0 Reactions
114 Views
(@pwrose2317)
Posts: 4
Active Member
Topic starter
 

I have applied the code below to VBA to activate the Spell Check feature on a protected worksheet.  My issue is when the code turns the protection back on, it does not capture the attributes attached to the original protection; i.e. the ability to insert or delete rows and columns which is key to this particular worksheet.

The code is;

Sub SpellCheck()
    Application.ScreenUpdating = False
On Error Resume Next
    With ActiveSheet
        .Unprotect ("**")
        Selection.CheckSpelling
        .Protect ("
**")
    End With
    Application.ScreenUpdating = True
End Sub

Thanks,

Prescott

 
Posted : 08/08/2017 9:20 am
(@kingtamo)
Posts: 13
Active Member
 

Hello

May be this piece of code would be useful for you

Sub Test()
Dim myPassword As String

myPassword = "123"

'Protect Worksheet (Allow Formatting Columns)
ActiveSheet.Protect Password:=(myPassword), AllowFormattingColumns:=True

'Protect Worksheet (Allow Formatting Rows)
ActiveSheet.Protect Password:=(myPassword), AllowFormattingRows:=True

'Protect Worksheet (Allow Formatting Columns & Rows)
ActiveSheet.Protect Password:=(myPassword), AllowFormattingColumns:=True, AllowFormattingRows:=True
End Sub

 
Posted : 08/08/2017 1:11 pm
(@pwrose2317)
Posts: 4
Active Member
Topic starter
 

Thanks, seemed to resolve the issue.

 
Posted : 08/08/2017 4:29 pm
(@kingtamo)
Posts: 13
Active Member
 

You're welcome. Glad I can offer some help

 
Posted : 09/08/2017 2:48 am
Share: