|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
系统里导出的原始表格,原始表格部分单元格可能有错误的原因,左上角有绿色三角符号。现在合并多个此类表格,代码如下。结果复制后的部分结果就成科学计数的格式了。请问如何设置代码,完整展示结果?
Sub 文件合并()
Dim Num As Long 'dim为定义参数
Dim insert_row As Long
Dim MyPath As String
Dim MyName As String
Dim Wb As Workbook 'dim被合并文件名
Application.DisplayAlerts = False
insert_row = 1
MyPath = ThisWorkbook.Path
MyName = Dir(MyPath & "\*.xls")
Num = 0
[A1].CurrentRegion.ClearContents
Do While MyName <> ""
If MyName <> ActiveWorkbook.Name Then
Set Wb = Workbooks.Open(MyPath & "/" & MyName)
Num = Num + 1
With Sheets("sheet1").Activate
If Num = 1 Then
If Range("A" & (Cells.SpecialCells(xlCellTypeLastCell).Row - 1)).Value = "合计行" Then
Range("A3", "BV" & (Cells.SpecialCells(xlCellTypeLastCell).Row - 2)).Select
Else
Range("A3", "BV" & (Cells.SpecialCells(xlCellTypeLastCell).Row - 1)).Select
End If
Else
If Range("A" & (Cells.SpecialCells(xlCellTypeLastCell).Row - 1)).Value = "合计行" Then
Range("A4", "BV" & (Cells.SpecialCells(xlCellTypeLastCell).Row - 2)).Select
Else
Range("A4", "BV" & (Cells.SpecialCells(xlCellTypeLastCell).Row - 1)).Select
End If
End If
End With
Selection.Copy
ActiveWindow.Close
Range("A" & insert_row).Select
Selection.PasteSpecial Paste:=xlPasteAll
insert_row = Range("A" & Rows.Count).End(xlUp).Row + 1 'End(xlUp).Row指数据区域最后一行行号
End If
MyName = Dir
Loop
End Sub
|
|