View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson[_3_] Dave Peterson[_3_] is offline
external usenet poster
 
Posts: 2,824
Default Show/Hide a Secret Cell

I think that this does the same as your code:

Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Dim myRng As Range
Set myRng = Range("a1:i1")

myRng.Font.ColorIndex = 15 'grey text

If Intersect(Target, Range("a1:i1")) Is Nothing Then
'do nothing
Else
Target.Font.ColorIndex = 1 ' black text
End If

End Sub

Hotbird wrote:

Option Explicit
Dim I As Integer
Dim Add As String
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

For I = 1 To 9
Select Case I
Case 1: Add = "$A$1"
Case 2: Add = "$B$1"
Case 3: Add = "$C$1"
Case 4: Add = "$D$1"
Case 5: Add = "$E$1"
Case 6: Add = "$F$1"
Case 7: Add = "$G$1"
Case 8: Add = "$H$1"
Case 9: Add = "$I$1"
End Select
If Target.Address = Add Then
Target.Font.ColorIndex = 1 ' black text
Else
Range(Add).Font.ColorIndex = 15 'grey text
End If
Next I
End Sub


--

Dave Peterson