excel中提取月份

Set up a Master sheet in your workbook, and add month sheets automatically, based on that Master sheet. The new sheets will be named for the month and year, in yyyy_mm format.

在您的工作簿中设置一个母版表,并基于该母版表自动添加月份表。 新工作表将以yyyy_mm格式命名为月份和年份。

自动添加月份表 (Add Month Sheets Automatically)

This video shows the steps for setting up the master sheet and macros, to add month sheets automatically in a workbook. Written details are below the video.

该视频显示了设置主表和宏的步骤,以在工作簿中自动添加月表。 书面详细信息在视频下方。

演示地址

创建一个主表 (Create a Master Sheet)

The first step is to set up a Master sheet in your workbook. In my sample file, the sheet is named wkst_Master.

第一步是在工作簿中设置一个母版表。 在我的示例文件中,工作表名为wkst_Master。

It has a named Excel table, tblSales, starting in cell A1.

它具有一个命名的Excel表tblSales,从单元格A1开始。

主表冻结窗格 (Master Sheet Freeze Pane)

To save time in the new sheets, be sure that the Master sheet is set up exactly the way you want it.

为了节省新表中的时间,请确保完全按照所需的方式设置母表。

In my sample file, there is a Freeze Pane setting, with the first row frozen at the top.

在我的示例文件中,有一个“冻结窗格”设置 ,第一行冻结在顶部。

This keeps the table's heading row visible, when you scroll down on the sheet.

当您在工作表上向下滚动时,这使表格的标题行保持可见。

主表所选单元格 (Master Sheet Selected Cell)

Another setting that I made on the Master sheet was to select cell A1. It's a minor thing, but it saves you the time of selecting that cell  on each new sheet that's created.

我在“母版”表上进行的另一项设置是选择单元格A1。 这是一件小事,但可以节省您在创建的每个新工作表上选择该单元格的时间。

宏来添加月份表 (Macro to Add Month Sheets)

In the sample file, there is a macro to add month sheets automatically, as needed.

在示例文件中,有一个宏可以根据需要自动添加月表。

This macro, named AddMonthWkst, is stored on a regular code module, named modSheets, and does the following steps:

这个宏,名为AddMonthWkst,被存储在一个普通的代码模块 ,名为modSheets,并执行以下操作步骤:

  • sets the sheet which will be used as the Master设置将用作母版的图纸
  • calculates the current year and month name, in yyyy_mm format以yyyy_mm格式计算当前的年和月名称
  • checks for a sheet with that year/month name检查具有该年/月名称的工作表
  • if not found, it creates a new sheet, based on Wkst_Master如果找不到,它将基于Wkst_Master创建一个新工作表
  • names new sheet with current year and month用当前年份和月份命名新工作表

宏代码添加月份表 (Macro Code to Add Month Sheets)

Here is the code for the AddMonthWkst macro.

这是AddMonthWkst宏的代码。

NOTE: You can change the master sheet name, and the date formatting, to match what you need in your workbook.

注意 :您可以更改主工作表名称和日期格式,以匹配您的工作簿中需要的内容。

Sub AddMonthWkst()
Dim ws As Worksheet
Dim wsM As Worksheet
Dim strName As String
Dim bCheck As Boolean
On Error Resume Next
Set wsM = Sheets("Wkst_Master")
strName = Format(Date, "yyyy_mm")
bCheck = Len(Sheets(strName).Name) > 0
If bCheck = False Then
'add new sheet after Instructions
wsM.Copy After:=Sheets(1)
ActiveSheet.Name = strName
End If
Set wsM = Nothing
End Sub

工作簿开放代码 (Workbook Open Code)

To make that macro run automatically when the workbook opens, there is code in the ThisWorkbook module too.

为了使该宏在工作簿打开时自动运行, ThisWorkbook模块中也有代码 。

The code is in the Workbook_Open event, and all it does is run the AddMonthWkst macro.

该代码在Workbook_Open事件中,并且所有操作都运行AddMonthWkst宏。

Private Sub Workbook_Open()
AddMonthWkst
End Sub

测试月度表宏 (Test the Month Sheets Macro)

After you add the Workbook_Open code and the AddMonthWkst macro code to your workbook, close the workbook, and then open it again.

将Workbook_Open代码和AddMonthWkst宏代码添加到您的工作簿后,关闭工作簿,然后再次将其打开。

If a security warning appears, click Enable Content, to allow the macros to run.

如果出现安全警告,请单击“启用内容”以允许宏运行。

Then, if the workbook doesn't already have a sheet for the current month, a new sheet will be automatically added, named with the year and month.

然后,如果工作簿在当月还没有工作表,则会自动添加新的工作表,并以年和月命名。

获取样本文件 (Get the Sample File)

To see how the code works, and add month sheets automatically, get my sample file from my Contextures website.

若要查看代码的工作原理并自动添加月工作表,请从Contextures网站获取示例文件。

Go to the Excel Worksheet Macros page, and get the sample file from the Download section.

转到“ Excel工作表宏”页面 ,并从“下载”部分获取示例文件。

翻译自: https://contexturesblog.com/archives/2019/05/09/add-month-sheets-automatically-in-excel/

excel中提取月份


http://www.taodudu.cc/news/show-6445710.html

相关文章:

  • 解决win10 的代理 IE可以正常代理,但chrome无法使用
  • VC 修改IE代理服务器
  • 侦测IE的代理服务器
  • 让IE部分网站或IP进行代理访问
  • 怎样检测你的IE使用的代理服务器
  • Java中使用IE Proxy代理的方法
  • IE代理问题
  • Windows 系统IE各版本浏览器的用户代理字符串
  • 【饭谈】ChatGpt如果让软件ui都消失的话,那ui自动化测试该何去何从?
  • 前端酷炫的n个UI设计效果网站
  • UI的恶梦
  • 漂亮的UI设计
  • UI妹子说我用CSS实现毛玻璃效果的样子很帅
  • 【前端UI框架推荐】六个前端[web端]精致UI框架
  • 「秘」那些管 UI 小姐姐要来的网站!
  • 「颜值即正义」那些管UI的妹子要来的网站啦
  • linux环境qt输入框不能切换中文输入法是什么原因
  • JLINK V8驱动
  • jlink 固件升级
  • JLINK_Windows_V6.10i 驱动免费下载地址
  • jlink驱动安装
  • stm32 --如何安装J-Link驱动软件
  • Jlink新版驱动安装目录无JLinkDevices.xml添加新器件方法
  • 【并行计算】Slurm的学习笔记
  • [slurm] CentOS7/Ubuntu18上Slurm部署步骤(单机版)
  • SLURM 安装与配置
  • 打开word出现安装cad解决方法
  • CAD图纸如何免费导出成Word文档?
  • CAD密技巧之如何将world文档快速插入CAD图纸
  • 欧洲语言参照标准C2,成都排名前十的德语培训班-排行榜

excel中提取月份_在Excel中自动添加月份表相关推荐

  1. mybatis在指定库建表_使用MyBatis Plus自动添加数据库表中的创建时间、创建者、更新时间、更新者...

    使用到Sringboot.Mybatis Plus.Shiro.Mysql 1.创建一张部门表,表结构 CREATE TABLE `sys_dept` ( `dept_id` bigint(20) N ...

  2. excel导入数据校验_使用Excel数据验证限制日期范围

    excel导入数据校验 Yesterday, one of my clients emailed to let me know that she was having trouble entering ...

  3. excel表格计算年龄_在Excel中计算年龄

    excel表格计算年龄 Can you remember how old you are? Or are you like me, and have to ask, "What year i ...

  4. excel函数提取计算机登录名,Excel查找函数FIND,帮你从复杂的地址中提取城市、区和街道名!-提取文件名...

    你还在为如何从纷繁的地址中提取出城市.区域和路/街名而苦恼么?还在为怎样从复杂的文件路径中提取出文件名而忧心么?别担心,查找函数FIND帮您快速解决这两大难题. 函数解析: FIND 函数有3个参数, ...

  5. excel下拉隐藏_在Excel下拉列表中隐藏使用过的项目

    excel下拉隐藏 You can add a drop down list in a cell, to make it easy for people to enter data. It's rea ...

  6. excel箱形图中位数_在Excel中创建简单的箱形图

    excel箱形图中位数 A box plot (box and whisker chart) lets you show how numbers are distributed in a set of ...

  7. excel 多行插入_在Excel中插入多行

    excel 多行插入 If you've used Excel for a while, you have lots of skills that you might assume everyone ...

  8. excel共享工作簿_在Excel中避免共享工作簿

    excel共享工作簿 Occasionally a client asks me to create a shared workbook in Excel, so two or more employ ...

  9. word2013插入excel对象报错_在 Excel 电子表格中插入对象

    如果在 Excel 或支持 OLE 的任何程序(如 Word)之间复制信息,可以将信息复制为 链接对象 或 嵌入对象 . 链接对象与嵌入对象之间的主要区别是数据存储位置,以及对象在放置到目标位置后 目 ...

最新文章

  1. java反射 面试题_使用Java反射更改私有静态最终字段
  2. 他在 B 站有 140 万粉丝,今天来免费带你学 Linux 了!
  3. 单元测试02:Open-Cover安装与使用
  4. html如何在本页路径上拼接参数,Html图片路径拼接参数实现打印导出
  5. (原創) 無論設計軟體硬體,拿到spec後,第一件事情就是model (OO)
  6. 如果一小时后永久断网,你会干嘛?
  7. JavaScript参考文档
  8. Java类集框架——List接口
  9. MPI + OpenMP实现快速排序
  10. 实验室家具系列之通风柜
  11. formate在python_python的format方法
  12. 关于抽象类的实验(java 内部类、多态等练习)
  13. eNSP:静态路由的负载分担
  14. 【hash】兔子与兔子(C++)
  15. 高博14讲--第三讲 三维空间刚体运动
  16. FreeModbus-移植到stm32f103
  17. matlab工具箱计算最小生成树_matlab_bgl 图论基本函数库, 相当丰富.包含工具箱、 、Dijkstra最短路径、 254万源代码下载- www.pudn.com...
  18. 交易心理学:会买的是徒弟,会卖的是师傅
  19. jQurry实现PC详情页分享到微信、朋友圈、QQ空间、微博
  20. 【ANSYS软件发展及学习准备】

热门文章

  1. 【TV Picture Quality - 04】TV常见操作界面
  2. 转载:传说中的T检验
  3. 【Unity】虚拟相机跟随Player移动并输出jpg图片
  4. (转) 选择 NET Framework 3.5 SP1 系统必备,ClickOnce 发布提示缺少文件的解决方案
  5. ppt提示内存或系统资源不足_存储空间不足无法处理此命令是什么原因?内存够却提示空间不足...
  6. Lambda正则表达式
  7. Fluent多孔介质模拟固体区域(观点)
  8. MATLAB和Python最优控制问题
  9. 瞎姬霸写之为什么我的生活越来越没意思
  10. 【求职】有关面试和简历相关的总结与心得