#1   Report Post  
Posted to microsoft.public.excel.misc
Ed T
 
Posts: n/a
Default change cell color

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Cells.FormatConditions.Delete
With Target.EntireRow
.FormatConditions.Add Type:=xlExpression, Formula1:="TRUE"
With .FormatConditions(1)
With .Borders(xlTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 5
End With
With .Borders(xlBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 5
End With
End With
.FormatConditions(1).Interior.ColorIndex = 20
End With

End Sub

How can I make this work with a write protected worksheet?
  #3   Report Post  
Posted to microsoft.public.excel.misc
Ed T
 
Posts: n/a
Default change cell color

This code works good, is there anyway to keep the formulas from showing in
the formula bar?

"Norman Jones" wrote:

Hi Ed,

Try:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Me.Unprotect "YourPassord"

'your code

Me.Protect "YourPassord"

End Sub


---
Regards,
Norman


"Ed T" <Ed wrote in message
...
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Cells.FormatConditions.Delete
With Target.EntireRow
.FormatConditions.Add Type:=xlExpression, Formula1:="TRUE"
With .FormatConditions(1)
With .Borders(xlTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 5
End With
With .Borders(xlBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 5
End With
End With
.FormatConditions(1).Interior.ColorIndex = 20
End With

End Sub

How can I make this work with a write protected worksheet?




  #4   Report Post  
Posted to microsoft.public.excel.misc
Norman Jones
 
Posts: n/a
Default change cell color

Hi Ed,

This code works good, is there anyway to keep the formulas from
showing in the formula bar?


Try something like:

'=============
Public Sub Tester()
Dim SH As Worksheet
Dim rng As Range
Const PWORD As String = "ABC" '<<==== CHANGE

Set SH = ThisWorkbook.Sheets("Sheet1") '<<==== CHANGE

SH.Unprotect Password:=PWORD
On Error Resume Next
Set rng = SH.Cells.SpecialCells(xlCellTypeFormulas)
On Error GoTo 0

If Not rng Is Nothing Then
With rng
.Locked = True
.FormulaHidden = True
End With
End If

SH.Protect Password:=PWORD

End Sub
'<<=============

Incidentally, it is advisable to post separate questions in a new thread.
This is not only to accord with established group etiquette but to
facilitate coherent Google storage and, not least, to maximise your
prospects of receiving viable assistance.


---
Regards,
Norman


  #5   Report Post  
Posted to microsoft.public.excel.misc
Ed T
 
Posts: n/a
Default change cell color

Hi Norman,

Thanks for your help; I was able to make it work by allowing user to format
cells on the protection box.

Regards,
Ed

"Norman Jones" wrote:

Hi Ed,

This code works good, is there anyway to keep the formulas from
showing in the formula bar?


Try something like:

'=============
Public Sub Tester()
Dim SH As Worksheet
Dim rng As Range
Const PWORD As String = "ABC" '<<==== CHANGE

Set SH = ThisWorkbook.Sheets("Sheet1") '<<==== CHANGE

SH.Unprotect Password:=PWORD
On Error Resume Next
Set rng = SH.Cells.SpecialCells(xlCellTypeFormulas)
On Error GoTo 0

If Not rng Is Nothing Then
With rng
.Locked = True
.FormulaHidden = True
End With
End If

SH.Protect Password:=PWORD

End Sub
'<<=============

Incidentally, it is advisable to post separate questions in a new thread.
This is not only to accord with established group etiquette but to
facilitate coherent Google storage and, not least, to maximise your
prospects of receiving viable assistance.


---
Regards,
Norman





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
Custom functions calculating time arguments Help Desperate Bill_De Excel Worksheet Functions 12 April 25th 06 02:22 AM
cell pointer color change go2laj Setting up and Configuration of Excel 0 March 26th 06 11:49 PM
How to change the default Border, Font Color, and Cell Color Elijah Excel Discussion (Misc queries) 3 November 2nd 05 11:52 PM
How do I change the color of the indicator cell in row and column Jim the Estimator Excel Worksheet Functions 1 July 27th 05 12:31 PM
Identifying the Active Fill Color Steve Conary Excel Discussion (Misc queries) 3 December 9th 04 04:45 AM


All times are GMT +1. The time now is 04:27 PM.

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"