I have a sheet2 that populates from data entered in sheet1. I would like to put borders around the data in sheet2 only if there is data (text) present (is not null) and no borders on cells with no data.
Thanks!
I have a sheet2 that populates from data entered in sheet1. I would like to put borders around the data in sheet2 only if there is data (text) present (is not null) and no borders on cells with no data.
Thanks!
try this macro
Sub Macro2()
Dim a As Variant
Cells.Select
Range("a3").Activate
Selection.Find(What:="", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False).Activate
a = ActiveCell.Address
Cells.Select
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlNotEqual, _
Formula1:="=" & a
With Selection.FormatConditions(1).Borders(xlLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.FormatConditions(1).Borders(xlRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.FormatConditions(1).Borders(xlTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.FormatConditions(1).Borders(xlBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Range("a1").Select
End Sub
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks