Colour fill within a range

P

Paul Watkins

Hi
I have a spreadsheet that i want people to be able to colour cells in using
a macro
I also only want them to colour specific cells. A3 to Z25
The sheet is protected ,and to enable them to colour cells i have a macro
which first unprotects- colours the active cell - reprotects.
is there any way that i can prevent people from colouring cells that they
are not supposed to.(e.g A1)

I Only want people to colour cells between Column A Row 3 and Column Z row
25.
This is the macro:

Sub Macro1()
On Error Resume Next

ThisWorkbook.Worksheets("paint").Unprotect
ThisWorkbook.Worksheets("paint").Select
Selection.Font.ColorIndex = 0
With Selection.Interior
.ColorIndex = 3
.Pattern = xlSolid
End With
ThisWorkbook.Worksheets("paint").Protect
End Sub


Thanks in advance
Paul
 
R

Ron de Bruin

Hi Paul

Try this

Sub Macro1()
If ActiveSheet.Name <> "paint" Then Exit Sub
If Selection.Cells.Count <> 1 Then Exit Sub
If Not Application.Intersect(Range("A3:Z25"), Selection) Is Nothing Then
With Worksheets("paint")
.Unprotect
.Selection.Font.ColorIndex = 0
With Selection.Interior
.ColorIndex = 3
.Pattern = xlSolid
End With
.Protect
End With
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top