• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Add Border If There Is Text

Matthew Berg

New Member
Looking to create a Macro that will add a border if there is Text.

Rows 1 & 2 are fixed and don't require borders,
Rows 3 to 100 will require borders (if there is text - I have a macro that will populate this)

Only require for Columns A - I
So I guess my range would be A3-I100

Standard Border

Thanks!
 
Hi Matthew ,

Is Conditional Formatting an option ?

If yes , then just select your range of A3:I100 , and enter the formula :

=ISTEXT(A3)

and select the border style you want.

What this will do is format any cell which has text data using the specified border style. If a cell contains numeric data , it will not be formatted.

If CF is not an option because your macro will be overwriting a cell's formats , then you can incorporate the following segment of code into your existing macro :

Code:
Public Sub InsertBorders()
           With ActiveSheet.Range("A3:I100")
                On Error Resume Next
                .FormatConditions.Delete
                On Error GoTo 0
              
                .FormatConditions.Add xlExpression, , "=ISTEXT(A3)"
                With .FormatConditions(1).Borders
                     .LineStyle = xlContinuous
                     .Weight = xlThin
                     .ColorIndex = 0
                End With
           End With
End Sub
Narayan
 
My columns are a mixture of names, dates, cities, and numbers. Is there an alternate/option for Conditional Formatting that will allow for any content?
 
Back
Top