本文概述
- Excel中宏的重要性
- 宏基础知识
- 如何编写宏

文章图片
Excel中宏的重要性 你可以将数据导入格式和Excel。每天你都需要执行相同的仪式。它可能变得无聊和无趣。
宏通过使这些例行任务自动化来解决此类问题。因此你可以使用宏来记录以下步骤
- 导入数据。
- 你正在格式化它以满足你的业务报告要求。
宏被攻击者用来破坏你的系统。他们在excel中被禁用。如果要运行宏, 则需要启用正在运行的宏, 并且仅运行你认为它来自受信任来源的宏。
如果要保存宏, 则必须以启用宏的格式* .xlsm保护工作簿, 并且宏名称不应包含任何空格。
如何编写宏 让我们看一下如何逐步编写一个简单的宏, 例如:
步骤1:在excel中转??到文件→选项。
步骤2:单击“自定义功能区”选项卡, 然后选择“开发人员”。
【什么是宏()】步骤3:点击“确定”按钮。

文章图片
步骤4:在驱动器E中创建一个名为srcmini的文件夹。
步骤5:并粘贴你下载的Annual-enterprise-survey.csv文件。

文章图片
步骤6:“开发人员”选项卡出现在菜单栏中。
步骤7:点击Developer(开发人员)栏。

文章图片
步骤6:然后点击Record Macro(记录宏)。

文章图片
步骤7:将出现一个对话框。
- 输入宏名称。
- 默认情况下, 输入了存储宏。
- 输入描述, 如以下屏幕截图所示。
- 单击确定按钮。

文章图片
步骤8:点击Data(数据)选项卡。
第9步:然后单击“来自文本”按钮。
步骤10:然后你将获得下面的屏幕快照中显示的对话框窗口。
- 转到存储CSV文件的本地驱动器。
- 选择该CSV文件。
- 单击导入按钮。

文章图片
步骤11:在那之后, 你将获得“文本导入向导”窗口。
- 单击定界复选框。
- 另外, 选择我的数据具有标题选项。
- 单击下一步按钮。

文章图片
第11步:选择逗号选项作为定界符, 然后单击下一步按钮。

文章图片
步骤12:
- 选择常规选项。
- 然后单击完成按钮。

文章图片
完成上述所有步骤之后, 你将在下面的屏幕截图中显示你的工作簿:

文章图片
要完成宏, 请单击“停止录制”宏选项, 如以下屏幕截图所示。

文章图片
步骤13:点击Macros(宏)按钮。
- 选择名为importMacro1的宏。
- 单击运行按钮。

文章图片