#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default borders

Is there a way to check wether an active cell is bordered?

If ActiveCell is bordered Then
--- action ---
End If

Thank you very much in advance
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,092
Default borders

If ActiveCell.Borders.LineStyle 0 Then

Mike F
"jobra" wrote in message
...
Is there a way to check wether an active cell is bordered?

If ActiveCell is bordered Then
--- action ---
End If

Thank you very much in advance



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default borders

Mike & jobra,

Some of the Linestyle's return less that zero, eg xlDash (-4115 ), xlDouble
(-4119), and others.

Sub test()
Dim s As String
Dim v As Variant
v = ActiveCell.Borders.LineStyle
If IsNull(v) Then
'less than 4 borders and/or mixed styles
s = "mixed borders"
ElseIf v = xlLineStyleNone Then
s = "no borders"
Else
s = "got 4 same style borders"
End If
MsgBox s
End Sub

Regards,
Peter T

"Mike Fogleman" wrote in message
...
If ActiveCell.Borders.LineStyle 0 Then

Mike F
"jobra" wrote in message
...
Is there a way to check wether an active cell is bordered?

If ActiveCell is bordered Then
--- action ---
End If

Thank you very much in advance





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default borders

Thank you very much Peter you are right about the differences. Mike thanks as
well for you time

"Peter T" wrote:

Mike & jobra,

Some of the Linestyle's return less that zero, eg xlDash (-4115 ), xlDouble
(-4119), and others.

Sub test()
Dim s As String
Dim v As Variant
v = ActiveCell.Borders.LineStyle
If IsNull(v) Then
'less than 4 borders and/or mixed styles
s = "mixed borders"
ElseIf v = xlLineStyleNone Then
s = "no borders"
Else
s = "got 4 same style borders"
End If
MsgBox s
End Sub

Regards,
Peter T

"Mike Fogleman" wrote in message
...
If ActiveCell.Borders.LineStyle 0 Then

Mike F
"jobra" wrote in message
...
Is there a way to check wether an active cell is bordered?

If ActiveCell is bordered Then
--- action ---
End If

Thank you very much in advance






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 129
Default borders

Hi,

how about something like this:

Function HasBorder(Cell As Range) As Boolean
Dim i As Variant
For Each i In Array(xlDiagonalDown, xlDiagonalUp, _
xlEdgeLeft, xlEdgeTop, xlEdgeBottom, xlEdgeRight)
If Cell(1).Borders(i).LineStyle < xlLineStyleNone Then
HasBorder = True
Exit For
End If
Next
End Function

Sub Test()
If HasBorder(ActiveCell) Then

End If
End Sub

this also detects borders of adjacent cells. if you don't want them,
use xlLeft, xlTop, xlBottom and xlRight instead of xlEdge***.
(even if a cell has no borders, adjacent cells may display borders)

this doesn't detect borders displayed by a conditional formatting.
perhaps there is no easy way to detect them without evaluating
conditions.

--
HTH,

okaizawa


jobra wrote:
Is there a way to check wether an active cell is bordered?

If ActiveCell is bordered Then
--- action ---
End If

Thank you very much in advance

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
borders mhenley5 Excel Discussion (Misc queries) 2 May 5th 09 11:09 PM
Borders Tucker Excel Discussion (Misc queries) 2 May 15th 07 06:41 AM
borders wdm0970 Excel Discussion (Misc queries) 1 September 26th 06 09:31 PM
borders Brush Prairie Excel Discussion (Misc queries) 0 August 23rd 05 02:57 AM
Help with borders Ed[_10_] Excel Programming 0 July 23rd 03 08:07 PM


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