Option Explicit
Sub 合并生成报表()
Dim i As Integer
Dim j As Integer
Dim N As Integer
Dim Filename(100) As String
Dim Stemp As String
Dim sFile As String
Dim FileCount As Integer
sFile = ActiveWorkbook.Name
With Application.FileDialog(msoFileDialogOpen)
Rows("3:65536").Clear '清空汇总表
.Title = "选择文件(可多选)"
.AllowMultiSelect = True
.Filters.Add "Excel Files", "*.xls"
.FilterIndex = 2 '默认的文件筛选条件的索引号
.Show
FileCount = .SelectedItems.Count
If FileCount = 0 Then Exit Sub
Filename(1) = .SelectedItems(1)
For i = 1 To FileCount
Filename(i) = .SelectedItems(i)
Next i
End With
For i = 1 To FileCount
Workbooks.Open (Filename(i))
For j = 1 To ActiveWorkbook.Sheets.Count
Sheets(j).Activate
N = ActiveSheet.UsedRange.Rows.Count
Stemp = "AR5" & ":BG" & N 'D5-S5以下所有数据
Range(Stemp).Select
Selection.Copy
Workbooks(sFile).Activate
N = ActiveSheet.Range("A65536").End(xlUp).Row
If N = 1 Then N = 0
Cells(N + 1, 1).Select
ActiveSheet.Paste
Stemp = Right(Filename(i), Len(Filename(i)) - InStrRev(Filename(i), "\"))
Workbooks(Stemp).Activate
Next j
ActiveWorkbook.Close
Next i
End Sub
EXCEL表合并,现在是粘贴公式,能改成粘贴时只粘贴数值吗?
答案:2 悬赏:50 手机版
解决时间 2021-04-10 09:59
- 提问者网友:不要迷恋哥
- 2021-04-09 18:26
最佳答案
- 五星知识达人网友:拜訪者
- 2021-04-09 19:57
activesheet.paste 改成
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
全部回答
- 1楼网友:举杯邀酒敬孤独
- 2021-04-09 21:35
把所有的引用地址改成绝对引用就可以了,如b2改成$b$2
改完后为:
=syd($b$2,$h$2,$d$2,year($a$6)-year($a$5))
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯