首页 文章

Excel VBA范围大文件

提问于
浏览
0

Excel 2013 / Win7

目标:确定大小:#Rows /#Cols,工作表对于excel来说太大了 .

我试过用:

Dim sh as worksheet
For each sh in ActiveWorkbook.Sheets
    'These are just my preferred ways of finding the ending points.
    LastRow = ActiveSheet.Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    LastCol = ActiveSheet.Cells.Find("*", SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column
    BlahBlah 'code that prints LastRow and LastCol to my userform
Next sh

这样可以正常工作,但它只给出了工作表的统计数据<=最大excel行数

所以玩文件改变扩展名从.xlsx到.zip并转到xl / Worksheets / sheet1.xml我注意到这一行: "<dimension ref="A3:C178"/>' 我有什么方法来获取这个参考 .

1 回答

  • 0

    为什么不尝试最后一个细胞呢?
    另外,为什么不在将.xls转换为.zip之前取这个值?

    Dim LastRow As Long
    Dim LastColumn As Long
    
    LastRow = sh.Cells.SpecialCells(xlCellTypeLastCell).Row
    LastColumn = sh.Cells.SpecialCells(xlCellTypeLastCell).Column
    

相关问题