如何使用macrosselect填充单元格的范围

我在sheet3中有一个button。在button单击事件中,我正在调用一个macros。在macros中,我想select填充在sheet13中的单元格的数量。如何执行此操作

您不能select单元格而不改变工作表的焦点。

Sheets("sheet13").Activate ActiveSheet.UsedRange.Select 

但是,您可以应用更改或从另一张表中读取数据而不改变焦点。

 Sheets("sheet13").UsedRange.Font.Bold = True Msgbox Sheets("sheet13").UsedRange.Cells.Count 

作为Variant说,你不能select单元格而不改变你的工作表的焦点。

但是你可以使用SpecialCells来select单元格

 Sub tester() Dim x1 As Range Dim x2 As Range Dim bigRange As Range Sheets("sheet2").Select 'the page you need Range("E9").Select ' any select will do Selection.SpecialCells(xlCellTypeFormulas, 23).Select 'select numbers, text, etc. Set x1 = Selection Range("E9").Select ' any select will do Selection.SpecialCells(xlCellTypeConstants, 23).Select 'select formulas Set x2 = Selection Set bigRange = Application.Union(x1, x2) 'join both ranges bigRange.Select Sheets("sheet1").Select 'return to the page with the button End Sub 

SpecialCells的帮助有什么可以select的附加信息。