+ Reply to Thread
Results 1 to 5 of 5

borders

  1. #1
    jobra
    Guest

    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. #2
    Mike Fogleman
    Guest

    Re: borders

    If ActiveCell.Borders.LineStyle > 0 Then

    Mike F
    "jobra" <[email protected]> wrote in message
    news:[email protected]...
    > 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. #3
    Peter T
    Guest

    Re: 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" <[email protected]> wrote in message
    news:[email protected]...
    > If ActiveCell.Borders.LineStyle > 0 Then
    >
    > Mike F
    > "jobra" <[email protected]> wrote in message
    > news:[email protected]...
    > > 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. #4
    jobra
    Guest

    Re: 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" <[email protected]> wrote in message
    > news:[email protected]...
    > > If ActiveCell.Borders.LineStyle > 0 Then
    > >
    > > Mike F
    > > "jobra" <[email protected]> wrote in message
    > > news:[email protected]...
    > > > 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. #5
    okaizawa
    Guest

    Re: 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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1