Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default UDF - detect cell border

I'm struggling with a simple UDF (it might require 2). I'd
like to return TRUE/FALSE if a cell has a top *or* bottom
border. Something like:

Function IsBorder(cell As Range) As Boolean
IsBorder = cell.Borders(xlEdgeTop)
End Function

Thanks!
Jason
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default UDF - detect cell border

Jason,

Try something like

Function HasBorder(Rng As Range) As Boolean
If Rng.Borders(xlEdgeTop).LineStyle < xlNone Or _
Rng.Borders(xlEdgeBottom).LineStyle < xlNone Then
HasBorder = True
Else
HasBorder = False
End If
End Function


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Jason Morin" wrote in message
...
I'm struggling with a simple UDF (it might require 2). I'd
like to return TRUE/FALSE if a cell has a top *or* bottom
border. Something like:

Function IsBorder(cell As Range) As Boolean
IsBorder = cell.Borders(xlEdgeTop)
End Function

Thanks!
Jason



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default UDF - detect cell border



Function Isborder(cell As Range) as Boolean
Dim bTop As Boolean, bBottom As Boolean
Application.Volatile
bTop = True
bBottom = True
With cell.Borders(xlEdgeTop)
If .Weight = 2 And .LineStyle = -4142 _
And .ColorIndex = -4142 Then
bTop = False
End If
End With
With cell.Borders(xlEdgeBottom)
If .Weight = 2 And .LineStyle = -4142 _
And .ColorIndex = -4142 Then
bBottom = False
End If
End With
Isborder = bTop Or bBottom
End Function

--
Regards,
Tom Ogilvy


"Jason Morin" wrote in message
...
I'm struggling with a simple UDF (it might require 2). I'd
like to return TRUE/FALSE if a cell has a top *or* bottom
border. Something like:

Function IsBorder(cell As Range) As Boolean
IsBorder = cell.Borders(xlEdgeTop)
End Function

Thanks!
Jason



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
border on last cell of page effects border on beginning cell of ne GaryE Excel Discussion (Misc queries) 0 March 23rd 09 05:47 AM
Detect Cell Colour MayJuneJuly Charts and Charting in Excel 1 July 22nd 08 09:56 PM
How to detect characters with a cell? Eric Excel Discussion (Misc queries) 12 June 26th 07 03:08 PM
Changing the border of one cell s/n change the border of adjacent gjanssenmn Excel Discussion (Misc queries) 2 October 5th 05 08:35 PM
Detect when Active Cell Changes GarethG[_8_] Excel Programming 1 October 22nd 03 02:16 PM


All times are GMT +1. The time now is 01:34 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"