Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 8
Default 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   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 449
Default 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   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 8
Default 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
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
Theme color doesn't change when I click it? Rachey Excel Worksheet Functions 1 March 5th 08 09:30 PM
Need a button to click to toggle cell color on/off Tonso Excel Discussion (Misc queries) 2 February 7th 07 01:31 PM
Right Click Fill Color Chipmunk Excel Discussion (Misc queries) 4 November 28th 05 09:42 PM
How do you change the color of a hyperlink after you click on it? Husker87 Excel Worksheet Functions 1 June 11th 05 06:07 PM
Change cell back color on click Dave Peterson Excel Discussion (Misc queries) 0 January 24th 05 10:50 PM


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