+ Reply to Thread
Results 1 to 5 of 5

Border cells with less code?

  1. #1
    XP
    Guest

    Border cells with less code?

    I am using Office 2003 on Windows XP.

    Drawing borders around cells seems so code intensive. Is there a shorter way
    to accomplish the following (which simply boxes a range of cells)?

    PLEASE NOTE: I tried "BorderAround," but this does not add the "inside
    vertical" borders. This can be accomplished with one click of the toolbar
    button, but in code...

    With [A10:N10]
    .Borders(xlEdgeTop).Weight = xlThin
    .Borders(xlEdgeBottom).Weight = xlThin
    .Borders(xlEdgeLeft).Weight = xlThin
    .Borders(xlEdgeRight).Weight = xlThin
    .Borders(xlInsideVertical).Weight = xlThin
    .Borders(xlInsideHorizontal).Weight = xlThin
    End With

    Is there something like a "BoxAround" method? I tried BorderAround, but this
    does not add the "inside vertical" borders.

    Thanks much in advance for your input.

  2. #2
    Philip
    Guest

    RE: Border cells with less code?

    try something like this

    Dim iBorder As XlBordersIndex

    For iBorder = xlEdgeLeft To xlEdgeRight
    With [A10:N10]
    .Borders(iBorder).Weight = xlThin
    End With
    Next

    HTH

    Philip

    "XP" wrote:

    > I am using Office 2003 on Windows XP.
    >
    > Drawing borders around cells seems so code intensive. Is there a shorter way
    > to accomplish the following (which simply boxes a range of cells)?
    >
    > PLEASE NOTE: I tried "BorderAround," but this does not add the "inside
    > vertical" borders. This can be accomplished with one click of the toolbar
    > button, but in code...
    >
    > With [A10:N10]
    > .Borders(xlEdgeTop).Weight = xlThin
    > .Borders(xlEdgeBottom).Weight = xlThin
    > .Borders(xlEdgeLeft).Weight = xlThin
    > .Borders(xlEdgeRight).Weight = xlThin
    > .Borders(xlInsideVertical).Weight = xlThin
    > .Borders(xlInsideHorizontal).Weight = xlThin
    > End With
    >
    > Is there something like a "BoxAround" method? I tried BorderAround, but this
    > does not add the "inside vertical" borders.
    >
    > Thanks much in advance for your input.


  3. #3
    Jim Thomlinson
    Guest

    RE: Border cells with less code?

    Range("A10", "N10").Borders.Weight = xlThin

    --
    HTH...

    Jim Thomlinson


    "XP" wrote:

    > I am using Office 2003 on Windows XP.
    >
    > Drawing borders around cells seems so code intensive. Is there a shorter way
    > to accomplish the following (which simply boxes a range of cells)?
    >
    > PLEASE NOTE: I tried "BorderAround," but this does not add the "inside
    > vertical" borders. This can be accomplished with one click of the toolbar
    > button, but in code...
    >
    > With [A10:N10]
    > .Borders(xlEdgeTop).Weight = xlThin
    > .Borders(xlEdgeBottom).Weight = xlThin
    > .Borders(xlEdgeLeft).Weight = xlThin
    > .Borders(xlEdgeRight).Weight = xlThin
    > .Borders(xlInsideVertical).Weight = xlThin
    > .Borders(xlInsideHorizontal).Weight = xlThin
    > End With
    >
    > Is there something like a "BoxAround" method? I tried BorderAround, but this
    > does not add the "inside vertical" borders.
    >
    > Thanks much in advance for your input.


  4. #4
    XP
    Guest

    RE: Border cells with less code?

    It was so simple, I couldn't figure it out... ;-)

    Thanks Jim!

    "Jim Thomlinson" wrote:

    > Range("A10", "N10").Borders.Weight = xlThin
    >
    > --
    > HTH...
    >
    > Jim Thomlinson
    >
    >
    > "XP" wrote:
    >
    > > I am using Office 2003 on Windows XP.
    > >
    > > Drawing borders around cells seems so code intensive. Is there a shorter way
    > > to accomplish the following (which simply boxes a range of cells)?
    > >
    > > PLEASE NOTE: I tried "BorderAround," but this does not add the "inside
    > > vertical" borders. This can be accomplished with one click of the toolbar
    > > button, but in code...
    > >
    > > With [A10:N10]
    > > .Borders(xlEdgeTop).Weight = xlThin
    > > .Borders(xlEdgeBottom).Weight = xlThin
    > > .Borders(xlEdgeLeft).Weight = xlThin
    > > .Borders(xlEdgeRight).Weight = xlThin
    > > .Borders(xlInsideVertical).Weight = xlThin
    > > .Borders(xlInsideHorizontal).Weight = xlThin
    > > End With
    > >
    > > Is there something like a "BoxAround" method? I tried BorderAround, but this
    > > does not add the "inside vertical" borders.
    > >
    > > Thanks much in advance for your input.


  5. #5
    XP
    Guest

    RE: Border cells with less code?

    Thanks!

    "Philip" wrote:

    > try something like this
    >
    > Dim iBorder As XlBordersIndex
    >
    > For iBorder = xlEdgeLeft To xlEdgeRight
    > With [A10:N10]
    > .Borders(iBorder).Weight = xlThin
    > End With
    > Next
    >
    > HTH
    >
    > Philip
    >
    > "XP" wrote:
    >
    > > I am using Office 2003 on Windows XP.
    > >
    > > Drawing borders around cells seems so code intensive. Is there a shorter way
    > > to accomplish the following (which simply boxes a range of cells)?
    > >
    > > PLEASE NOTE: I tried "BorderAround," but this does not add the "inside
    > > vertical" borders. This can be accomplished with one click of the toolbar
    > > button, but in code...
    > >
    > > With [A10:N10]
    > > .Borders(xlEdgeTop).Weight = xlThin
    > > .Borders(xlEdgeBottom).Weight = xlThin
    > > .Borders(xlEdgeLeft).Weight = xlThin
    > > .Borders(xlEdgeRight).Weight = xlThin
    > > .Borders(xlInsideVertical).Weight = xlThin
    > > .Borders(xlInsideHorizontal).Weight = xlThin
    > > End With
    > >
    > > Is there something like a "BoxAround" method? I tried BorderAround, but this
    > > does not add the "inside vertical" borders.
    > >
    > > Thanks much in advance for your input.


+ 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