I am trying to run the following code but it only works when
Is it possible use
What I am trying to do is format the
Sheet5
is active. Am I right in thinking that the Offset()
property tries to select a range.Is it possible use
Offset()
with the sheet being active?
VBA Code:
For Each named_range In ActiveWorkbook.Names
If Left(named_range.Name, 6) <> "_xlfn." Then
If named_range.RefersToRange.Parent.Name = ActiveSheet.Name Then
With Sheet5.range(named_range.Name).Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlHairline
End With
With Sheet5.range(named_range.Name).range(Cells(1, 1), Cells(Sheet5.range(named_range.Name).Rows.Count, 1)).Offset(0, 32).Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlMedium
End With
End If
End If
Next named_range
What I am trying to do is format the
xlEdgeLeft
border of the range of cells in the column after the range as sometimes I hide the last few columns of the range depending on the length of the month. This will always give me the border I need at the end of the range.