Is it possible to display a value based on presence of a cell border?

447 views Asked by At

We are looking at doing some data import. There is a very large complex sheet which has some items grouped together using borders around cells in one column. The only indication that the items are grouped is the fact the group is surrounded by a border. Items ungrouped have no left and right border on the cell (may have top and bottom border as items above and below maybe grouped). As an initial exercise we want to add a column that displays true if an item is grouped. So if there is a border display a value like one. Does anyone know if this possible?

1

There are 1 answers

2
ttaaoossuuuu On BEST ANSWER

Use this custom VBA function:

Public Function GetBorder(ByVal Rng As Range, Idx As Integer) As Boolean
    GetBorder = Rng.Borders(Idx).LineStyle <> xlNone
End Function

It takes two arguments: cell and index of border (7=left, 8=bottom, 9=top, 10=right). Returns TRUE or FALSE. Now if you want to get info about bottom border of cell A1 you should:

=GetBorder(A1,8)