Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
on double click change cell color
I put this code in the worksheet's code module
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, _ Cancel As Boolean) 'on double click change color to show selection If Not Intersect(Target, Range("A15")) Is Nothing Then Target.Select With Selection.Interior .ColorIndex = 42 .Pattern = xSolid End With Cancel = True End If End Sub But the Target is not changing to the desired color. I've tried to change the Range part to other values and nothing works. Can anybody see what I'm doing wrong? As usual any help will be most appreciated! -- gaba :) |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
on double click change cell color
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, _
Cancel As Boolean) 'on double click change color to show selection If Target.Address = "$A$15" Then With Target.Interior .ColorIndex = 42 .Pattern = xlSolid End With Cancel = True End If End Sub You misspelled the constant xlSolid -- Regards, Tom Ogilvy "gaba" wrote in message ... I put this code in the worksheet's code module Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, _ Cancel As Boolean) 'on double click change color to show selection If Not Intersect(Target, Range("A15")) Is Nothing Then Target.Select With Selection.Interior .ColorIndex = 42 .Pattern = xSolid End With Cancel = True End If End Sub But the Target is not changing to the desired color. I've tried to change the Range part to other values and nothing works. Can anybody see what I'm doing wrong? As usual any help will be most appreciated! -- gaba :) |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
on double click change cell color
:)
Thanks Tom. I'm not feeling pretty smart right now... "Tom Ogilvy" wrote: Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, _ Cancel As Boolean) 'on double click change color to show selection If Target.Address = "$A$15" Then With Target.Interior .ColorIndex = 42 .Pattern = xlSolid End With Cancel = True End If End Sub You misspelled the constant xlSolid -- Regards, Tom Ogilvy "gaba" wrote in message ... I put this code in the worksheet's code module Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, _ Cancel As Boolean) 'on double click change color to show selection If Not Intersect(Target, Range("A15")) Is Nothing Then Target.Select With Selection.Interior .ColorIndex = 42 .Pattern = xSolid End With Cancel = True End If End Sub But the Target is not changing to the desired color. I've tried to change the Range part to other values and nothing works. Can anybody see what I'm doing wrong? As usual any help will be most appreciated! -- gaba :) |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
on double click change cell color
Don't feel bad. I missed it too when I tested your code. It is funny that
setting the Pattern to 0 would override the colorindex property (set it to xlNone / -4142). At least it is not intuitive at first glance. -- Regards, Tom Ogilvy "gaba" wrote in message ... :) Thanks Tom. I'm not feeling pretty smart right now... "Tom Ogilvy" wrote: Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, _ Cancel As Boolean) 'on double click change color to show selection If Target.Address = "$A$15" Then With Target.Interior .ColorIndex = 42 .Pattern = xlSolid End With Cancel = True End If End Sub You misspelled the constant xlSolid -- Regards, Tom Ogilvy "gaba" wrote in message ... I put this code in the worksheet's code module Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, _ Cancel As Boolean) 'on double click change color to show selection If Not Intersect(Target, Range("A15")) Is Nothing Then Target.Select With Selection.Interior .ColorIndex = 42 .Pattern = xSolid End With Cancel = True End If End Sub But the Target is not changing to the desired color. I've tried to change the Range part to other values and nothing works. Can anybody see what I'm doing wrong? As usual any help will be most appreciated! -- gaba :) |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
on double click change cell color
Tom, it's funny you mention the xlNone (are you reading my mind?). That's
what I'm trying to do next... if I double click on the colored cell, go back to clear color (Pattern set to 0) Thanks for your help. I'm teaching myself and some days (like today) small things look pretty big Gaba "Tom Ogilvy" wrote: Don't feel bad. I missed it too when I tested your code. It is funny that setting the Pattern to 0 would override the colorindex property (set it to xlNone / -4142). At least it is not intuitive at first glance. -- Regards, Tom Ogilvy "gaba" wrote in message ... :) Thanks Tom. I'm not feeling pretty smart right now... "Tom Ogilvy" wrote: Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, _ Cancel As Boolean) 'on double click change color to show selection If Target.Address = "$A$15" Then With Target.Interior .ColorIndex = 42 .Pattern = xlSolid End With Cancel = True End If End Sub You misspelled the constant xlSolid -- Regards, Tom Ogilvy "gaba" wrote in message ... I put this code in the worksheet's code module Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, _ Cancel As Boolean) 'on double click change color to show selection If Not Intersect(Target, Range("A15")) Is Nothing Then Target.Select With Selection.Interior .ColorIndex = 42 .Pattern = xSolid End With Cancel = True End If End Sub But the Target is not changing to the desired color. I've tried to change the Range part to other values and nothing works. Can anybody see what I'm doing wrong? As usual any help will be most appreciated! -- gaba :) |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
on double click change cell color
Unless you have a need to change the pattern, I would leave it alone. If
you want to toggle the coloration of A15: Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, _ Cancel As Boolean) 'on double click change color to show selection If Target.Address = "$A$15" Then With Target.Interior If .ColorIndex = xlNone Then .ColorIndex = 42 Else .ColorIndex = xlNone End If End With Cancel = True End If End Sub -- Regards, Tom Ogilvy "gaba" wrote in message ... Tom, it's funny you mention the xlNone (are you reading my mind?). That's what I'm trying to do next... if I double click on the colored cell, go back to clear color (Pattern set to 0) Thanks for your help. I'm teaching myself and some days (like today) small things look pretty big Gaba "Tom Ogilvy" wrote: Don't feel bad. I missed it too when I tested your code. It is funny that setting the Pattern to 0 would override the colorindex property (set it to xlNone / -4142). At least it is not intuitive at first glance. -- Regards, Tom Ogilvy "gaba" wrote in message ... :) Thanks Tom. I'm not feeling pretty smart right now... "Tom Ogilvy" wrote: Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, _ Cancel As Boolean) 'on double click change color to show selection If Target.Address = "$A$15" Then With Target.Interior .ColorIndex = 42 .Pattern = xlSolid End With Cancel = True End If End Sub You misspelled the constant xlSolid -- Regards, Tom Ogilvy "gaba" wrote in message ... I put this code in the worksheet's code module Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, _ Cancel As Boolean) 'on double click change color to show selection If Not Intersect(Target, Range("A15")) Is Nothing Then Target.Select With Selection.Interior .ColorIndex = 42 .Pattern = xSolid End With Cancel = True End If End Sub But the Target is not changing to the desired color. I've tried to change the Range part to other values and nothing works. Can anybody see what I'm doing wrong? As usual any help will be most appreciated! -- gaba :) |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Cell requires double click to 'activate' date format change | Excel Discussion (Misc queries) | |||
How to change syperlink from single click to double click | Excel Worksheet Functions | |||
Click on graph bar to execute a double-click in a pivot table cell | Charts and Charting in Excel | |||
Change cell back color on click | Excel Discussion (Misc queries) | |||
how do I: click in cell and make it change color? | Excel Programming |