我现在用vb将从数据库里读出的数据导入到excel中去,由于导出数据个数的不确定性
,导致excel中行数的不确定,所以我想给有数的那些单元格加上边框,以显得象张报
表。
还请各位同仁不吝赐教,谢谢。

解决方案 »

  1.   


    Sheet1.UsedRange.Rows.Count能够得到使用行数
      

  2.   

        Range(Cells(1, 1), Cells(Sheet3.UsedRange.Rows.Count, Sheet3.UsedRange.Columns.Count)).Select
        Selection.Borders(xlDiagonalDown).LineStyle = xlNone
        Selection.Borders(xlDiagonalUp).LineStyle = xlNone
        With Selection.Borders(xlEdgeLeft)
            .LineStyle = xlContinuous
            .Weight = xlThin
            .ColorIndex = xlAutomatic
        End With
        With Selection.Borders(xlEdgeTop)
            .LineStyle = xlContinuous
            .Weight = xlThin
            .ColorIndex = xlAutomatic
        End With
        With Selection.Borders(xlEdgeBottom)
            .LineStyle = xlContinuous
            .Weight = xlThin
            .ColorIndex = xlAutomatic
        End With
        With Selection.Borders(xlEdgeRight)
            .LineStyle = xlContinuous
            .Weight = xlThin
            .ColorIndex = xlAutomatic
        End With
        With Selection.Borders(xlInsideVertical)
            .LineStyle = xlContinuous
            .Weight = xlThin
            .ColorIndex = xlAutomatic
        End With
        With Selection.Borders(xlInsideHorizontal)
            .LineStyle = xlContinuous
            .Weight = xlThin
            .ColorIndex = xlAutomatic
        End With