在excel里怎样将多个工作表里的数据整理成一个图表
发布网友
发布时间:2022-04-29 16:45
我来回答
共1个回答
热心网友
时间:2023-10-20 08:04
在某个盘里面建个文件夹,存放所有需要合并的工作表比如在D盘里面建立一个文件夹hb,然后将工作表放到hb文件夹中在桌面新建一个excel打开-按Alt+F11在代码窗口里面输入以下内容: Sub wt()
On Error Resume Next
Dim fs, f, f1, fc, s, sCount, x
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder("d:\hb\") Set fc = f.Files
x = 0
For Each f1 In fc
If Right(f1.Name, 3) = "xls" Then
Workbooks.Open (f1.Path)
sCount = Workbooks(2).Worksheets.Count
For s = 1 To sCount
Workbooks(2).Sheets(s).Select
Workbooks(2).Sheets(s).Copy After:=Workbooks(1).Sheets(x + s)
Next
x = x + sCount
Workbooks(2).Close savechanges = False
End If
Next
Application.DisplayAlerts = False
Workbooks(1).Sheets(1).Delete
Application.DisplayAlerts = True
End Sub
然后按F5运行这样所有工作表里面的内容都会合并到这个工作表内
热心网友
时间:2023-10-20 08:04
在某个盘里面建个文件夹,存放所有需要合并的工作表比如在D盘里面建立一个文件夹hb,然后将工作表放到hb文件夹中在桌面新建一个excel打开-按Alt+F11在代码窗口里面输入以下内容: Sub wt()
On Error Resume Next
Dim fs, f, f1, fc, s, sCount, x
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder("d:\hb\") Set fc = f.Files
x = 0
For Each f1 In fc
If Right(f1.Name, 3) = "xls" Then
Workbooks.Open (f1.Path)
sCount = Workbooks(2).Worksheets.Count
For s = 1 To sCount
Workbooks(2).Sheets(s).Select
Workbooks(2).Sheets(s).Copy After:=Workbooks(1).Sheets(x + s)
Next
x = x + sCount
Workbooks(2).Close savechanges = False
End If
Next
Application.DisplayAlerts = False
Workbooks(1).Sheets(1).Delete
Application.DisplayAlerts = True
End Sub
然后按F5运行这样所有工作表里面的内容都会合并到这个工作表内
热心网友
时间:2023-10-20 08:04
在某个盘里面建个文件夹,存放所有需要合并的工作表比如在D盘里面建立一个文件夹hb,然后将工作表放到hb文件夹中在桌面新建一个excel打开-按Alt+F11在代码窗口里面输入以下内容: Sub wt()
On Error Resume Next
Dim fs, f, f1, fc, s, sCount, x
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder("d:\hb\") Set fc = f.Files
x = 0
For Each f1 In fc
If Right(f1.Name, 3) = "xls" Then
Workbooks.Open (f1.Path)
sCount = Workbooks(2).Worksheets.Count
For s = 1 To sCount
Workbooks(2).Sheets(s).Select
Workbooks(2).Sheets(s).Copy After:=Workbooks(1).Sheets(x + s)
Next
x = x + sCount
Workbooks(2).Close savechanges = False
End If
Next
Application.DisplayAlerts = False
Workbooks(1).Sheets(1).Delete
Application.DisplayAlerts = True
End Sub
然后按F5运行这样所有工作表里面的内容都会合并到这个工作表内
热心网友
时间:2023-10-20 08:04
在某个盘里面建个文件夹,存放所有需要合并的工作表比如在D盘里面建立一个文件夹hb,然后将工作表放到hb文件夹中在桌面新建一个excel打开-按Alt+F11在代码窗口里面输入以下内容: Sub wt()
On Error Resume Next
Dim fs, f, f1, fc, s, sCount, x
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder("d:\hb\") Set fc = f.Files
x = 0
For Each f1 In fc
If Right(f1.Name, 3) = "xls" Then
Workbooks.Open (f1.Path)
sCount = Workbooks(2).Worksheets.Count
For s = 1 To sCount
Workbooks(2).Sheets(s).Select
Workbooks(2).Sheets(s).Copy After:=Workbooks(1).Sheets(x + s)
Next
x = x + sCount
Workbooks(2).Close savechanges = False
End If
Next
Application.DisplayAlerts = False
Workbooks(1).Sheets(1).Delete
Application.DisplayAlerts = True
End Sub
然后按F5运行这样所有工作表里面的内容都会合并到这个工作表内