VB Sheet Protect while allowing only font color changes.

petrosj

New Member
Joined
Jan 11, 2018
Messages
1
I have VB code running to allow multiple items to be selected from a drop down. The VB code also unlocks and locks the sheet before and after. However, users have the need to proof read the text that others submit and I require that they make deletions in red text and additions in blue text. I am unable to figure out how to allow 5 cells to be unlocked for font color only, nothing else. Is there a way to only allow font color to be changed in these 5 cells in my VB code as the last step? Or possibly I am thinking about this in the wrong way and it needs to be done another way. Corrections or suggestions would be welcomed as well as I am stuck. My VB code is below, and the cells that I require users to be able to change font color are: D55, D56, D57, D59, D62. Thank you very much in advance.

Private Sub Worksheet_Change(ByVal Target As Range)
Sheet1.Unprotect Password:="hi"
Dim Oldvalue As String
Dim Newvalue As String
Application.EnableEvents = True
On Error GoTo Exitsub
If Target.Address = "$D$16" Or Target.Address = "$D$24" Or Target.Address = "$D$31" Or Target.Address = "$D$35" Or Target.Address = "$D$58" Then
If Target.SpecialCells(xlCellTypeAllValidation) Is Nothing Then
GoTo Exitsub
Else: If Target.Value = "" Then GoTo Exitsub Else
Application.EnableEvents = False
Newvalue = Target.Value
Application.Undo
Oldvalue = Target.Value
If Oldvalue = "" Then
Target.Value = Newvalue
Else
If InStr(1, Oldvalue, Newvalue) = 0 Then
Target.Value = Oldvalue & ", " & Newvalue
Else:
Target.Value = Oldvalue
End If
End If
End If
End If
Application.EnableEvents = True
Exitsub:
Application.EnableEvents = True
Sheet1.Protect Password:="hi"
End Sub
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().

Forum statistics

Threads
1,224,823
Messages
6,181,177
Members
453,021
Latest member
Justyna P

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