代码之家  ›  专栏  ›  技术社区  ›  AviD

选择包含数据的所有单元格

  •  3
  • AviD  · 技术社区  · 16 年前

    我在找像这样的东西 ActiveSheet.SelectUsedCells

    2 回复  |  直到 6 年前
        1
  •  16
  •   RichieHindle    16 年前

    干得好:

    Range("A1").Select
    Range(Selection, Selection.End(xlToRight)).Select
    Range(Selection, Selection.End(xlDown)).Select
    

    或者,如果您不一定从A1开始:

    Range("C6").Select  ' Select a cell that you know you populated'
    Selection.End(xlUp).Select
    Selection.End(xlToLeft).Select
    Range(Selection, Selection.End(xlToRight)).Select
    Range(Selection, Selection.End(xlDown)).Select
    
        2
  •  15
  •   cyberponk    5 年前

    CurrentRegion 所有物这将选择一个以空单元格为边界的连续区域,因此根据工作表的格式,这可能是一种更优雅的方法。

    Range("A1").CurrentRegion.Select