+ Reply to Thread
Results 1 to 3 of 3

borders - tricky problem

  1. #1
    Registered User
    Join Date
    03-18-2005
    Posts
    5

    Question borders - tricky problem

    Hey everyone, i'm puzzled :-S


    Is it possible to write a macro that will place borders around any cell with text in it, while leaving empty cells un-bordered.


    any help very much appreciated,

    noviceNBAuser

  2. #2
    Registered User
    Join Date
    03-18-2005
    Posts
    5
    ok, had a think and I reckon conditional formatting is the easiest solution: I'm stuck in macro writting mode you see :-)

    thx anyways ppl :-)

    (p.s. still stuck on my text as a trigger for macro problem though - ref to earlier post. cheers)

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Joule,

    Placing a Border Around a Cell:
    Range("A1").BorderAround LineStyle:= xlBorderLineStyleContinuous, Weight:= xlThin

    Placing a Border Around a Range of Cells:
    Range("A1:D10").BorderAround LineStyle:= xlBorderLineStyleContinuous, Weight:= xlThin

    LineStyle Constants
    xlBorderLineStyleNone
    xlBorderLineStyleContinuous
    xlBorderLineStyleDash
    xlBorderLineStyleDot
    xlBorderLineStyleDouble


    Weight Constants
    xlHairline
    xlThin
    xlMedium
    xlThick


    Note: To remove the borders, set LineStyle = xlBorderLineStyleNone

    Macro to Add Borders to Cells with Text...
    _________________________________________________________________

    Public Sub AddBorder(ByVal Cell_Address As String)

    Dim DataType

    With ActiveSheet.Range(Cell_Address)
    DataType = .Value
    If VarType(DataType) = 8 Then
    .BorderAround = LineStyle:= xlBorderLineStyleContinuous, Weight:= xlThin
    End If
    End With

    End Sub
    _________________________________________________________________

    Usiing the Macro:

    AddBorder ("A1")

    If "A1" is a Text (Variant Type 8 = String) then add a border around the cell.


    Hope this helps,
    Leith Ross

+ 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