如何使用VBA在Excel中引用表? [英] How do I reference tables in Excel using VBA?

查看:124
本文介绍了如何使用VBA在Excel中引用表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Excel VBA中是否可以引用命名表?

Is it possible in Excel VBA to reference a named table?

假设地,这可能是...

Hypothetically this could be...

Sheets("Sheet1").Table("A_Table").Select

我已经看到一些表是列表对象的提法,但是我不确定这是否是同一件事.

I have seen some mention of tables being a list object but I'm not sure if that is the same thing.

推荐答案

将范围转换为表,如此答案:

Sub CreateTable()
    ActiveSheet.ListObjects.Add(xlSrcRange, Range("$B$1:$D$16"), , xlYes).Name = _
        "Table1"
        'No go in 2003
    ActiveSheet.ListObjects("Table1").TableStyle = "TableStyleLight2"
End Sub

这篇关于如何使用VBA在Excel中引用表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆