在Excel 2007中使用VBA添加/编辑表标题以创建宏 [英] Adding/Editing Table Headers using VBA in Excel 2007 to create a Macro

查看:146
本文介绍了在Excel 2007中使用VBA添加/编辑表标题以创建宏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在excel 2007中使用VBA创建一个表。该表已经有标题,但我希望它有excel的内置标题,因为它们提供下拉菜单,用户可以选择/取消选择要显示的信息。我想知道是否有
是一种向我的宏添加VBA代码的方法,这将允许删除列标题? (我知道在标题中添加空格会删除自动名称,例如第1列或数字),但我想知道是否有办法编辑代码以获取
关注此删除或者将标题留空(除了表格中已经存在的地方)?


另外,我在左侧有我的桌子的子标题,我想知道是否可以制作宏,以便副标题可以允许选择/取消选择要显示的信息?

感谢您的帮助!我很感激。

解决方案

在Excel VBA中编写任何代码之前,请尝试在用户界面中进行操作。当您添加表格时,如果您有标题,则可以选择.Default已经过检查,因此您的标题已包含在内,也会有下拉列表。


宏用于获取如下表格。

 Sub Macro2()ActiveSheet.ListObjects.Add(xlSrcRange,Range(" 


A


< BLOCKQUOTE> 1

I'm creating a table using VBA in excel 2007. The table has headings already, but I would like it to have the built in headers from excel since they provide drop down menus where the user can select/deselect information to show. I'm wondering if there is a way to add VBA code to my macro that will allow the column headers to be deleted? (I know that adding spaces in the header will get rid of the automated name, such as column 1 or a number), but I'm wondering if there is a way to edit the code to take care of this deleting or to leave the headings blank (except for where they already exist in my table)?
Also, I have sub-headings for my table on the left side, and I was wondering if it's possible to make macro such that the subheadings can allow for selecting/deselecting information to show?
Thanks for the help! I appreciate it.

解决方案

Before coding anything in Excel VBA try doing in User Interface.When you add table excel gives you option if you have headers or not.Default is checked so your headers are included and dropdowns are also there.

A macro is used for getting a table like below.

Sub Macro2()    ActiveSheet.ListObjects.Add(xlSrcRange, Range("


A


1:


这篇关于在Excel 2007中使用VBA添加/编辑表标题以创建宏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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