请教:首先选择A1:F15,执行宏(一键设置常用边框),第15行下框线有线条。但是当再选择下一页面A16:F26,再执行宏时,上一页第15行下框线变没了。经查找原因是第15行有分页符造成的,请高手帮忙看看原因 要实现的功能是:选择范围外框线条用xlMedium,内部竖线用 xlThin细线条,第一行和最后一行外框用粗线条。 Sub 一键设置常用边框() Dim myRange As Range Dim cell As Range Dim ws As Worksheet '获取当前选定范围 Set myRange = Selection Set ws = myRange.Worksheet '设置新的边框样式 With myRange.Borders(xlEdgeLeft) .LineStyle = xlContinuous .ColorIndex = 0 .TintAndShade = 0 .Weight = xlMedium End With With myRange.Borders(xlEdgeTop) .LineStyle = xlContinuous .ColorIndex = 0 .TintAndShade = 0 .Weight = xlMedium End With With myRange.Borders(xlEdgeBottom) .LineStyle = xlContinuous .ColorIndex = 0 .TintAndShade = 0 .Weight = xlMedium End With With myRange.Borders(xlEdgeRight) .LineStyle = xlContinuous .ColorIndex = 0 .TintAndShade = 0 .Weight = xlMedium End With With myRange.Borders(xlInsideVertical) .LineStyle = xlContinuous .ColorIndex = 0 .TintAndShade = 0 .Weight = xlThin End With '加粗第一行和最后一行的外框线 With myRange.Rows(1).Borders(xlEdgeTop) .LineStyle = xlContinuous .Weight = xlMedium End With With myRange.Rows(1).Borders(xlEdgeBottom) .LineStyle = xlContinuous .Weight = xlMedium End With With myRange.Rows(myRange.Rows.Count).Borders(xlEdgeTop) .LineStyle = xlContinuous .Weight = xlMedium End With With myRange.Rows(myRange.Rows.Count).Borders(xlEdgeBottom) .LineStyle = xlContinuous .Weight = xlMedium End With End Sub
|