惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Hacker News - Newest:
Hacker News - Newest: "LLM"
The Last Watchdog
The Last Watchdog
L
LINUX DO - 最新话题
Application and Cybersecurity Blog
Application and Cybersecurity Blog
T
Troy Hunt's Blog
Cloudbric
Cloudbric
N
News | PayPal Newsroom
Security Archives - TechRepublic
Security Archives - TechRepublic
TaoSecurity Blog
TaoSecurity Blog
H
Hacker News: Front Page
Help Net Security
Help Net Security
S
Secure Thoughts
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
PCI Perspectives
PCI Perspectives
AI
AI
Hacker News: Ask HN
Hacker News: Ask HN
NISL@THU
NISL@THU
Last Week in AI
Last Week in AI
Forbes - Security
Forbes - Security
The GitHub Blog
The GitHub Blog
D
DataBreaches.Net
Scott Helme
Scott Helme
Jina AI
Jina AI
T
Threatpost
W
WeLiveSecurity
P
Palo Alto Networks Blog
F
Fortinet All Blogs
腾讯CDC
人人都是产品经理
人人都是产品经理
云风的 BLOG
云风的 BLOG
博客园 - 【当耐特】
Apple Machine Learning Research
Apple Machine Learning Research
P
Privacy International News Feed
P
Proofpoint News Feed
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
A
About on SuperTechFans
V
Vulnerabilities – Threatpost
www.infosecurity-magazine.com
www.infosecurity-magazine.com
C
Cyber Attacks, Cyber Crime and Cyber Security
B
Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
D
Darknet – Hacking Tools, Hacker News & Cyber Security
IT之家
IT之家
美团技术团队
I
InfoQ
阮一峰的网络日志
阮一峰的网络日志
T
Threat Research - Cisco Blogs
博客园 - 司徒正美

博客园 - 鸡毛信

改变你思维模式的书单 金字塔原理 BA的广度和深度 读书雷达 l 业务分析师(BA)篇 How to easily concatenate text based on criteria in Excel? 如何将Excel中的文本按条件合并 BA Practice Lead Handbook 1 - Why Is Business Analysis Taking The World By Storm? Making the Elephant Dance: Strategic Enterprise Analysis BABOK - 企业分析(Enterprise Analysis) BA - 读书雷达10本必读书 XMind十大最有用的功能 Excel中如何查找并列出所有链接(外部数据链接)? 在Excel里如何将多个工作簿合并到一个工作簿中 用Excel完成专业化数据统计、分析工作 需求 BA/PM Competency Module PPT 学习总结 PPT五大插件汇总下载 提高你30%的设计效率的PPT快捷键 PPT扁平化手册 2
EXCEL 如何将多个工作表或工作簿合并到一个工作表
鸡毛信 · 2016-03-03 · via 博客园 - 鸡毛信

在使用Excel 时,我们经常需要将多个工作表或工作簿合并到一个工作表中,这样我们就能快速地对数据进行分析和统计。对于一般用户而言,除了复制每个工作表后再粘贴,没有其他什么方法了。如果只是合并少数几个工作表,这个方法很简单;如果要合并大量的工作表,这个方法非常耗时。现在,我们谈谈其他快速合并工作表或工作簿的方法。

下面的VBA 代码能帮你把当前工作簿里各个工作表里的数据合并到一个新工作表里。同时需要注意的是,所有工作表里的数据结构,列标题,以及各列排列的顺序都必须一样。操作如下:

1. 按住Alt + F11键打开 Microsoft Visual Basic for Applications窗口。

2. 点击插入 >> 模块,再将下面的代码粘贴到模块窗口里。

VBA:当前工作簿里各个工作表里的数据合并到一个新工作表里

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

Sub Combine()

 Dim As Integer

 On Error Resume Next

 Sheets(1).Select

 Worksheets.Add

 Sheets(1).Name = "Combined"

 Sheets(2).Activate

 Range("A1").EntireRow.Select

 Selection.Copy Destination:=Sheets(1).Range("A1")

 For J = 2 To Sheets.Count

 Sheets(J).Activate

 Range("A1").Select

 Selection.CurrentRegion.Select

 Selection.Offset(1, 0).Resize(Selection.Rows.Count - 1).Select

 Selection.Copy Destination:=Sheets(1).Range("A65536").End(xlUp)(2)

 Next

 End Sub

3. 按F5 键运行代码。运行后,当前工作簿里的数据都被并合并到一个名为 Combine的新 工作表中 , 并列在所有工作表前面。

注意:

(1) 数据必须从单元格A1开始,否则代码无效。

(2) 所有的工作表数据必须布局一致。

(3) 此代码只能合并当前工作簿里的工作表,如果想要合并多个工作簿里的工作表,此代码无效。

4. 保存文件为xlsm格式以便保存代码

 http://www.extendoffice.com/documents/excel/zh-cn-excel/2800-excel-merge-multiple-worksheets-into-one.html