PC Review


Reply
Thread Tools Rate Thread

Color 8 cells on DBL click

 
 
SoggyCashew
Guest
Posts: n/a
 
      3rd Jan 2010
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 With Quote
 
 
 
 
Harald Staff
Guest
Posts: n/a
 
      3rd Jan 2010
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" <(E-Mail Removed)> wrote in message
news:8BDEACF9-1787-439D-82F0-(E-Mail Removed)...
> 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 With Quote
 
SoggyCashew
Guest
Posts: n/a
 
      3rd Jan 2010
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" <(E-Mail Removed)> wrote in message
> news:8BDEACF9-1787-439D-82F0-(E-Mail Removed)...
> > 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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Color input vs formula cells with 1 click =?Utf-8?B?ZXhjZWwgZnJhbWVz?= Microsoft Excel Programming 0 8th Mar 2006 01:40 AM
change fill color of a range of cells based on color of a cell? =?Utf-8?B?RGFyTWVsTmVs?= Microsoft Excel Programming 0 2nd Mar 2006 06:35 PM
on click change cells color and increase a number.. =?Utf-8?B?RGFuaWVs?= Microsoft Excel Programming 2 19th Oct 2005 12:35 AM
Excel 2003 will not display color fonts or color fill cells =?Utf-8?B?RGF2ZUM=?= Microsoft Excel Worksheet Functions 1 11th Apr 2005 04:38 PM
My excel 2003 wont let me fill cells with color or color the tabs. =?Utf-8?B?dHJpem9n?= Microsoft Excel New Users 2 22nd Feb 2005 06:43 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:53 PM.