#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5
Default Shade a cell

I need a cell to get shaded when i click on it. how can i do that?
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,593
Default Shade a cell

'----------------------------------------------------------------
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'----------------------------------------------------------------
Cells.FormatConditions.Delete
With Target
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:="TRUE"
.FormatConditions(1).Interior.ColorIndex = 36
End With

End Sub


'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Lavanya" wrote in message
...
I need a cell to get shaded when i click on it. how can i do that?



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 468
Default Shade a cell

Caution!!
This will, of course, "destroy" any and all other conditional
formatting you have or need to maintain in the sheet.


"Bob Phillips" wrote:

'----------------------------------------------------------------
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'----------------------------------------------------------------
Cells.FormatConditions.Delete
With Target
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:="TRUE"
.FormatConditions(1).Interior.ColorIndex = 36
End With

End Sub


'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Lavanya" wrote in message
...
I need a cell to get shaded when i click on it. how can i do that?




  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,124
Default Shade a cell

Right click sheet tabview codeinsert this

'McCurdy.Here is something inspired by Don Guillett.
Private Sub Worksheet_selectionChange(ByVal Target As Range)
Dim MyRng As Range
Set MyRng = Target '.EntireRow
Application.EnableEvents = False
On Error GoTo end1
Application.Cells.FormatConditions.Delete
'Application.Cells.Font.Size = 10
With MyRng
.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=ROW()=ROW(INDIRECT(CELL(""address"")))"
With .FormatConditions(1).Font
.Bold = True
.Italic = False
.ColorIndex = 1
End With
'.Font.Size = 20
.FormatConditions(1).Interior.ColorIndex = 36
End With
end1:
Application.EnableEvents = True
End Sub

--
Don Guillett
SalesAid Software

"Lavanya" wrote in message
...
I need a cell to get shaded when i click on it. how can i do that?



  #8   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Shade a cell

I did before I posted.

I put 7 in A1.
I used a CF rule #1 of value = 7 and changed the fill color.
I finished up and the CF was in effect.

I added your code behind the worksheet and selected a different location. Then
back to A1 and my shading was gone. I looked at the CF rule and yours was in
its place.

What am I missing?

Don Guillett wrote:

Dave,

Test it. You can even add new.

--
Don Guillett
SalesAid Software

"Dave Peterson" wrote in message
...
You sure?

Application.Cells.FormatConditions.Delete

Looks like it would destroy any existing conditional formats.



Don Guillett wrote:

The one I posted will NOT

--
Don Guillett
SalesAid Software

"JMay" wrote in message
...
Caution!!
This will, of course, "destroy" any and all other conditional
formatting you have or need to maintain in the sheet.


"Bob Phillips" wrote:

'----------------------------------------------------------------
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'----------------------------------------------------------------
Cells.FormatConditions.Delete
With Target
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:="TRUE"
.FormatConditions(1).Interior.ColorIndex = 36
End With

End Sub


'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Lavanya" wrote in message
...
I need a cell to get shaded when i click on it. how can i do that?




--

Dave Peterson


--

Dave Peterson
  #9   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,124
Default Shade a cell


Sorry, I missed the CF reference.

--
Don Guillett
SalesAid Software

"Dave Peterson" wrote in message
...
I did before I posted.

I put 7 in A1.
I used a CF rule #1 of value = 7 and changed the fill color.
I finished up and the CF was in effect.

I added your code behind the worksheet and selected a different location.
Then
back to A1 and my shading was gone. I looked at the CF rule and yours was
in
its place.

What am I missing?

Don Guillett wrote:

Dave,

Test it. You can even add new.

--
Don Guillett
SalesAid Software

"Dave Peterson" wrote in message
...
You sure?

Application.Cells.FormatConditions.Delete

Looks like it would destroy any existing conditional formats.



Don Guillett wrote:

The one I posted will NOT

--
Don Guillett
SalesAid Software

"JMay" wrote in message
...
Caution!!
This will, of course, "destroy" any and all other conditional
formatting you have or need to maintain in the sheet.


"Bob Phillips" wrote:

'----------------------------------------------------------------
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'----------------------------------------------------------------
Cells.FormatConditions.Delete
With Target
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:="TRUE"
.FormatConditions(1).Interior.ColorIndex = 36
End With

End Sub


'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Lavanya" wrote in message
...
I need a cell to get shaded when i click on it. how can i do
that?




--

Dave Peterson


--

Dave Peterson



  #10   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Shade a cell

Whew! <vbg

Don Guillett wrote:

Sorry, I missed the CF reference.

--
Don Guillett
SalesAid Software

"Dave Peterson" wrote in message
...
I did before I posted.

I put 7 in A1.
I used a CF rule #1 of value = 7 and changed the fill color.
I finished up and the CF was in effect.

I added your code behind the worksheet and selected a different location.
Then
back to A1 and my shading was gone. I looked at the CF rule and yours was
in
its place.

What am I missing?

Don Guillett wrote:

Dave,

Test it. You can even add new.

--
Don Guillett
SalesAid Software

"Dave Peterson" wrote in message
...
You sure?

Application.Cells.FormatConditions.Delete

Looks like it would destroy any existing conditional formats.



Don Guillett wrote:

The one I posted will NOT

--
Don Guillett
SalesAid Software

"JMay" wrote in message
...
Caution!!
This will, of course, "destroy" any and all other conditional
formatting you have or need to maintain in the sheet.


"Bob Phillips" wrote:

'----------------------------------------------------------------
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'----------------------------------------------------------------
Cells.FormatConditions.Delete
With Target
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:="TRUE"
.FormatConditions(1).Interior.ColorIndex = 36
End With

End Sub


'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Lavanya" wrote in message
...
I need a cell to get shaded when i click on it. how can i do
that?




--

Dave Peterson


--

Dave Peterson


--

Dave Peterson


  #11   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 422
Default Shade a cell

FYI.................

Hey Guys... On this subject a few days back -- I was rummaging around
In my treasure-chest of macros and came across the following (which
allows
for the highlighting of the activecell WITHOUT affecting any previously
established Conditional Formatting.. << Pretty neat Your Comments?

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Static OldCell As Range
If Application.CutCopyMode = 0 Then
If Not OldCell Is Nothing Then
OldCell.Interior.ColorIndex = xlColorIndexNone
OldCell.Borders.LineStyle = xlLineStyleNone
End If
Set OldCell = Target
OldCell.Interior.ColorIndex = 6
OldCell.Borders.LineStyle = xlContinuous
Else
If OldCell Is Nothing Then
Set OldCell = Target
Else
Set OldCell = Union(OldCell, Target)
End If
End If
End Sub


Happy New Year !!
Thanks for all your help in 2006, 2005, 2004...!!



"Don Guillett" wrote in message
:

Sorry, I missed the CF reference.

--
Don Guillett
SalesAid Software

"Dave Peterson" wrote in message
...
I did before I posted.

I put 7 in A1.
I used a CF rule #1 of value = 7 and changed the fill color.
I finished up and the CF was in effect.

I added your code behind the worksheet and selected a different location.
Then
back to A1 and my shading was gone. I looked at the CF rule and yours was
in
its place.

What am I missing?

Don Guillett wrote:

Dave,

Test it. You can even add new.

--
Don Guillett
SalesAid Software

"Dave Peterson" wrote in message
...
You sure?

Application.Cells.FormatConditions.Delete

Looks like it would destroy any existing conditional formats.



Don Guillett wrote:

The one I posted will NOT

--
Don Guillett
SalesAid Software

"JMay" wrote in message
...
Caution!!
This will, of course, "destroy" any and all other conditional
formatting you have or need to maintain in the sheet.


"Bob Phillips" wrote:

'----------------------------------------------------------------
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'----------------------------------------------------------------
Cells.FormatConditions.Delete
With Target
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:="TRUE"
.FormatConditions(1).Interior.ColorIndex = 36
End With

End Sub


'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Lavanya" wrote in message
...
I need a cell to get shaded when i click on it. how can i do
that?




--

Dave Peterson


--

Dave Peterson


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
insert date Larry Excel Worksheet Functions 28 July 15th 06 02:41 AM
Compiling macro based on cell values simonsmith Excel Discussion (Misc queries) 1 May 16th 06 08:31 PM
Urgent date/scheduling calc needed jct Excel Worksheet Functions 3 February 24th 06 01:36 AM
Shade cell according to text? Ltat42a Excel Discussion (Misc queries) 0 January 3rd 06 06:37 PM
Copy cell format to cell on another worksht and update automatical kevinm Excel Worksheet Functions 21 May 19th 05 11:07 AM


All times are GMT +1. The time now is 04:35 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"