我有很多文件,它包含每个月的每一天的数据。 我需要将所有数据收集到主文件并为每个文件插入日期。 我在A1单元格中设置[第1天-1]并使用下面的代码将日期设置为每天范围但是效果不佳。任何帮助表示赞赏!
Do While buf <> ""
Set openWB = Workbooks.Open(fold_path & "\" & buf)
With openWB.ActiveSheet
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
LastCol = .Cells(1, .Columns.Count).End(xlToLeft).Column
.Range(.Cells(2, "A"), .Cells(LastRow, LastCol)).Copy
End With
With ThisWorkbook.Worksheets("GA")
.Range("B" & .Cells(.Rows.Count, "B").End(xlUp).Row + 1).PasteSpecial Paste:=xlPasteValues, _
Operation:=xlNone, SkipBlanks:=False, Transpose:=False
.Range(.Cells(Cells(.Rows.Count, "B").End(xlUp).Row, "A"), .Cells(.Cells(.Rows.Count, "A").End(xlUp).Row + 1, "A")).Value = .Cells(.Cells(.Rows.Count, "A").End(xlUp).Row, "A").Value + 1
End With
openWB.Close False
buf = Dir() Loop
答案 0 :(得分:0)
以这种方式尝试:
With ThisWorkbook.Worksheets("GA")
With .Cells(.Rows.count, "B").End(xlUp).Offset(1)
.Offset(, -1).value = .Offset(, -1).End(xlUp).value + 1
.PasteSpecial Paste:=xlPasteValues
End With
End With