Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Sub Error with Sheet Protection Enabled?

Hi All,

I am at a loss, I get an error in my sub when I try and run it with the
sheet protection enabled.
I've made sure the range of cells are not locked but it has no affect.
I'm sure that it has something to do with the fact that it is
Workbook_SheetSelectionChange type sub but I don't know how to rectify.
Any assistance would be welcome.

'This sub changes only the active cell with in the range green and bolds the
text in the cell beside the active green cell

Public Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As
Excel.Range)

If Intersect(Target, Range("D7:D9,F7:F9")) Is Nothing Then Exit Sub 'If
the selected cell is not in the range exit the sub
Static DataField As Range

If Not DataField Is Nothing Then

DataField.Interior.ColorIndex = xlNone

End If 'changes the offset cell text to bold
Target.Interior.ColorIndex = 4
With Target.Interior.ColorIndex = 4
ActiveCell.Offset(0, 1).Font.Bold = True
ActiveCell.Offset(0, 1).Font.ColorIndex = 3
End With
If Range("D7,F7").Interior.ColorIndex = xlNone Then
Range("E7,G7").Font.Bold = False
End If
If Range("D8,F8").Interior.ColorIndex = xlNone Then
Range("E8,G8").Font.Bold = False
End If
If Range("D9,F9").Interior.ColorIndex = xlNone Then
Range("E9,G9").Font.Bold = False
End If

Set DataField = Target

End Sub


Thanks in advance.
Pete


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Sub Error with Sheet Protection Enabled?

Public Sub Workbook_SheetSelectionChange( _
ByVal Sh As Object, ByVal Target As Excel.Range)

If Intersect(Target, Range("D7:D9,F7:F9")) Is Nothing Then Exit Sub 'If
the selected cell is not in the range exit the sub
Static DataField As Range

sh.unprotect password:="abcd"

If Not DataField Is Nothing Then

DataField.Interior.ColorIndex = xlNone

End If 'changes the offset cell text to bold
Target.Interior.ColorIndex = 4
With Target.Interior.ColorIndex = 4
ActiveCell.Offset(0, 1).Font.Bold = True
ActiveCell.Offset(0, 1).Font.ColorIndex = 3
End With
If Range("D7,F7").Interior.ColorIndex = xlNone Then
Range("E7,G7").Font.Bold = False
End If
If Range("D8,F8").Interior.ColorIndex = xlNone Then
Range("E8,G8").Font.Bold = False
End If
If Range("D9,F9").Interior.ColorIndex = xlNone Then
Range("E9,G9").Font.Bold = False
End If

Set DataField = Target

sh.protect password:="abcd"
End Sub


--
Regards,
Tom Ogilvy


pcsis wrote in message
news:cDuEb.111666$bC.102120@clgrps13...
Hi All,

I am at a loss, I get an error in my sub when I try and run it with the
sheet protection enabled.
I've made sure the range of cells are not locked but it has no affect.
I'm sure that it has something to do with the fact that it is
Workbook_SheetSelectionChange type sub but I don't know how to rectify.
Any assistance would be welcome.

'This sub changes only the active cell with in the range green and bolds

the
text in the cell beside the active green cell

Public Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target

As
Excel.Range)

If Intersect(Target, Range("D7:D9,F7:F9")) Is Nothing Then Exit Sub

'If
the selected cell is not in the range exit the sub
Static DataField As Range

If Not DataField Is Nothing Then

DataField.Interior.ColorIndex = xlNone

End If 'changes the offset cell text to bold
Target.Interior.ColorIndex = 4
With Target.Interior.ColorIndex = 4
ActiveCell.Offset(0, 1).Font.Bold = True
ActiveCell.Offset(0, 1).Font.ColorIndex = 3
End With
If Range("D7,F7").Interior.ColorIndex = xlNone Then
Range("E7,G7").Font.Bold = False
End If
If Range("D8,F8").Interior.ColorIndex = xlNone Then
Range("E8,G8").Font.Bold = False
End If
If Range("D9,F9").Interior.ColorIndex = xlNone Then
Range("E9,G9").Font.Bold = False
End If

Set DataField = Target

End Sub


Thanks in advance.
Pete




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error when opening a macro-enabled Excel 2007 file JRSCEI Excel Discussion (Misc queries) 0 January 11th 10 08:55 PM
Excel Data Protection Best Practice: AKA: Real Sheet Protection Mushman(Woof!)[_2_] Excel Discussion (Misc queries) 4 December 30th 09 01:20 AM
Cell/worksheet protection with macros enabled Zilla[_2_] Excel Worksheet Functions 7 March 6th 07 01:07 AM
ON AN EXCEL SPREAD SHEET TOOLS/PROTECTION/ (4TABS are not enabled dan Excel Discussion (Misc queries) 3 January 8th 07 08:03 PM
import data greyed out when protection enabled Robert Excel Discussion (Misc queries) 3 February 26th 06 09:30 PM


All times are GMT +1. The time now is 01:28 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"