|
Question : xlThick > VBA Conditional Formatting
|
|
I'm trying to run VBA for this conditional formatting as a user can't make a line "thick" in the normal way thru Edit > CF....
Is there a way to do in VBA. I'm getting an error when I change the xlThin to xlThick.
Range("f8").Select Selection.FormatConditions.Delete Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _ "=LEFT($B8,2)<>LEFT($B9,2)" 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 = xlThick .ColorIndex = xlAutomatic End With Selection.Copy Range("F8:M223").Select Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _ SkipBlanks:=False, Transpose:=False Range("F8").Select Application.CutCopyMode = False
Thanks
Andrew
|
|
Answer : xlThick > VBA Conditional Formatting
|
|
Yes, you can use VBA code to determine how to format the cells whenever a change is made to the sheet. You would use the Range.Borders property versus the Range.FormatConditions(1).Borders property. However, the formatting will get a little tricky as you will have to worry about situations were one cell is bordered and an adjacent one is not. In other words, you will not be able to set one cell's border to think, move to the next cell, and clear that cell's borders or you lose part of the first cell's borders.
Kevin
|
|
|
|