VBA将所有边界应用于范围

时间:2019-03-19 11:53:21

标签: excel vba

请帮助我提供我的代码。 A具有要应用“所有边界”的简单数据。行数将会改变

Sub Draw_Borbers()
Dim FO As Worksheet
Dim LastRow As Long
Dim AllRange As Range



Set FO = ThisWorkbook.Worksheets("Final Order")

LastRow = FO.Cells(Rows.Count, 1).End(xlUp).Row
Set AllRange = Range("A2:I2" & LastRow)

With AllRange.Borders
    .LineStyle = xlContinuous
    .Weight = xlThin
    .ColorIndex = 0
    .TintAndShade = 0

    End With

End Sub

问题是,当我只有361个非空行(基于A列)时,它为我提供了2361行的边框。

我认为是因为行数不清而添加了

.Columns("B:B").SpecialCells(xlCellTypeBlanks).EntireRow.Delete

到以前的宏,但是它仍然给我奇数的行数。

在以前的宏中,我从数据透视表中复制粘贴数据并删除一些行,但即使整个列表也仅包含651行...

非常感谢您的帮助!

0 个答案:

没有答案
相关问题