+ Reply to Thread
Results 1 to 3 of 3

Bordering

Hybrid View

  1. #1
    Ashish Mathur
    Guest

    Bordering

    Hi,

    I am just trying my hand with this macro. The purpose of this macro is to
    colour code the content of every alternate cell in the selected range to Blue
    (which is happening) and border it with a blue dotted box (which is not
    happening). I have written this code but it does not seem to work correctly.
    The macro should actually put a border around the cells in the selected
    range. However, it borders the active cell in the range and in the other
    alternate cell it just puts a border on three sides.


    Any help would be highly appreciated


    Sub Dotted_box()

    For Each c In ActiveCell.CurrentRegion.Cells
    If c.Column Mod 2 <> 0 Then

    ActiveCell.Font.ColorIndex = 5

    With ActiveCell.BorderAround(xlContinuous, xlHairline, 5)

    End With
    End If
    Next c

    Selection.Font.ColorIndex = 5

    With Selection.BorderAround(xlContinuous, xlHairline, 5)

    End With

    End Sub

    Regards,

  2. #2
    Vasant Nanavati
    Guest

    Re: Bordering

    All you need is:

    Sub Dotted_box()
    Dim c As Range
    For Each c In ActiveCell.CurrentRegion.Cells
    If c.Column Mod 2 <> 0 Then
    c.Font.ColorIndex = 5
    c.BorderAround xlContinuous, xlHairline, , 5
    End If
    Next
    End Sub

    --

    Vasant


    "Ashish Mathur" <mathurashish@hotmail.com> wrote in message
    news:84BEBF4E-7614-436B-B74A-0A0130458F5A@microsoft.com...
    > Hi,
    >
    > I am just trying my hand with this macro. The purpose of this macro is to
    > colour code the content of every alternate cell in the selected range to

    Blue
    > (which is happening) and border it with a blue dotted box (which is not
    > happening). I have written this code but it does not seem to work

    correctly.
    > The macro should actually put a border around the cells in the selected
    > range. However, it borders the active cell in the range and in the other
    > alternate cell it just puts a border on three sides.
    >
    >
    > Any help would be highly appreciated
    >
    >
    > Sub Dotted_box()
    >
    > For Each c In ActiveCell.CurrentRegion.Cells
    > If c.Column Mod 2 <> 0 Then
    >
    > ActiveCell.Font.ColorIndex = 5
    >
    > With ActiveCell.BorderAround(xlContinuous, xlHairline, 5)
    >
    > End With
    > End If
    > Next c
    >
    > Selection.Font.ColorIndex = 5
    >
    > With Selection.BorderAround(xlContinuous, xlHairline, 5)
    >
    > End With
    >
    > End Sub
    >
    > Regards,




  3. #3
    Yan-Hong Huang[MSFT]
    Guest

    RE: Bordering

    Hello,

    I was reviewing the issue thread. Vasant's suggestion should be OK for it.
    If you have any more concerns, please feel free to post here and we will
    follow up.

    Thanks very much.

    Best regards,
    Yanhong Huang
    Microsoft Community Support

    Get Secure! ¨C www.microsoft.com/security
    Register to Access MSDN Managed Newsgroups!
    -http://support.microsoft.com/default.aspx?scid=/servicedesks/msdn/nospam.as
    p&SD=msdn

    This posting is provided "AS IS" with no warranties, and confers no rights.


+ 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