在表格中选择动态范围-VBA

时间:2018-10-22 08:25:07

标签: excel vba excel-vba

我有一个excel表和一个窗体控件(按钮),该控件从表中选择特定数据并将其复制到邮件中。我想知道如何只选择表格中的几列,而不是全部。

请帮助,谢谢

这是我的代码的一部分:

Sub SendCA_list()

Call FilterCA 'filter the table per specific data

Range("Table4[[#Headers],[Department]]").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select 'select all the columns after the column 'department'- how to select only 10 coloumn?
ActiveWindow.SmallScroll Down:=-129
Selection.Copy

2 个答案:

答案 0 :(得分:2)

don't need to select anything

Range("Table4[[#All],[Column1]],Table4[[#All],[Column2]],Table4[[#All],[Column4]]").Copy

答案 1 :(得分:0)

@ShiraL尝试在列名称之前导入[#All]:

Range("Table4[[#All],[Department]:[Status]]").Select