Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.newusers
|
|||
|
|||
Color 8 cells on DBL click
Hello, If I clicked on a square/cell how could I get it to color a 4 X 4 cell
"8 cells all together" area with the cell that was clicked being the bottom left cell? I'm using this code to color the single cell. Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Excel.Range, Cancel As Boolean) Dim BorderColor As Long If Target.Interior.ColorIndex = 36 Then Target.Interior.ColorIndex = xlNone BorderColor = 0 Else Target.Interior.ColorIndex = 36 BorderColor = -16776961 End If With Target .Borders(xlEdgeLeft).LineStyle = xlContinuous .Borders(xlEdgeLeft).Color = BorderColor .Borders(xlEdgeTop).LineStyle = xlContinuous .Borders(xlEdgeTop).Color = BorderColor .Borders(xlEdgeBottom).LineStyle = xlContinuous .Borders(xlEdgeBottom).Color = BorderColor .Borders(xlEdgeRight).LineStyle = xlContinuous .Borders(xlEdgeRight).Color = BorderColor End With Cancel = True End Sub -- Thanks, Chad |
#2
Posted to microsoft.public.excel.newusers
|
|||
|
|||
Color 8 cells on DBL click
Hi Chad
4*4 is 16, not 8 ;-). Hope this get you started: Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Excel.Range, Cancel As Boolean) Dim BorderColor As Long Dim Rng As Range Cancel = True Set Rng = Target(1).Offset(-3, 0).Resize(4, 4) If Target(1).Interior.ColorIndex = 36 Then Rng.Interior.ColorIndex = xlNone Else Rng.Interior.ColorIndex = 36 End If End Sub HTH. Best wishes Harald "SoggyCashew" wrote in message ... Hello, If I clicked on a square/cell how could I get it to color a 4 X 4 cell "8 cells all together" area with the cell that was clicked being the bottom left cell? I'm using this code to color the single cell. Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Excel.Range, Cancel As Boolean) Dim BorderColor As Long If Target.Interior.ColorIndex = 36 Then Target.Interior.ColorIndex = xlNone BorderColor = 0 Else Target.Interior.ColorIndex = 36 BorderColor = -16776961 End If With Target .Borders(xlEdgeLeft).LineStyle = xlContinuous .Borders(xlEdgeLeft).Color = BorderColor .Borders(xlEdgeTop).LineStyle = xlContinuous .Borders(xlEdgeTop).Color = BorderColor .Borders(xlEdgeBottom).LineStyle = xlContinuous .Borders(xlEdgeBottom).Color = BorderColor .Borders(xlEdgeRight).LineStyle = xlContinuous .Borders(xlEdgeRight).Color = BorderColor End With Cancel = True End Sub -- Thanks, Chad |
#3
Posted to microsoft.public.excel.newusers
|
|||
|
|||
Color 8 cells on DBL click
Thanks a million that worked but how do I get the border red like before?
-- Thanks, Chad "Harald Staff" wrote: Hi Chad 4*4 is 16, not 8 ;-). Hope this get you started: Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Excel.Range, Cancel As Boolean) Dim BorderColor As Long Dim Rng As Range Cancel = True Set Rng = Target(1).Offset(-3, 0).Resize(4, 4) If Target(1).Interior.ColorIndex = 36 Then Rng.Interior.ColorIndex = xlNone Else Rng.Interior.ColorIndex = 36 End If End Sub HTH. Best wishes Harald "SoggyCashew" wrote in message ... Hello, If I clicked on a square/cell how could I get it to color a 4 X 4 cell "8 cells all together" area with the cell that was clicked being the bottom left cell? I'm using this code to color the single cell. Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Excel.Range, Cancel As Boolean) Dim BorderColor As Long If Target.Interior.ColorIndex = 36 Then Target.Interior.ColorIndex = xlNone BorderColor = 0 Else Target.Interior.ColorIndex = 36 BorderColor = -16776961 End If With Target .Borders(xlEdgeLeft).LineStyle = xlContinuous .Borders(xlEdgeLeft).Color = BorderColor .Borders(xlEdgeTop).LineStyle = xlContinuous .Borders(xlEdgeTop).Color = BorderColor .Borders(xlEdgeBottom).LineStyle = xlContinuous .Borders(xlEdgeBottom).Color = BorderColor .Borders(xlEdgeRight).LineStyle = xlContinuous .Borders(xlEdgeRight).Color = BorderColor End With Cancel = True End Sub -- Thanks, Chad . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Theme color doesn't change when I click it? | Excel Worksheet Functions | |||
Need a button to click to toggle cell color on/off | Excel Discussion (Misc queries) | |||
Right Click Fill Color | Excel Discussion (Misc queries) | |||
How do you change the color of a hyperlink after you click on it? | Excel Worksheet Functions | |||
Change cell back color on click | Excel Discussion (Misc queries) |