我有大约 30 个工作表(一个月中的几天),每张工作表上
我想将每个工作表上的范围A293:AL293
和值复制A296:AL296
到我的活动工作表中(例如,从每月 1 日到 30 日的连续行中)。
这些范围分别使用 MIN
和PERCENTILE
公式。但是,当我运行宏时,单元格包含 !REF 错误,因为复制的是公式而不是实际的单元格值。
我应该如何修改宏,使其复制和粘贴值而不是公式?
我从另一个用于将数据从 30 张纸复制并粘贴到一张纸中的宏修改的代码是:
Sub test()
Dim curRow As Integer
Dim activeWorksheet As Worksheet
Set activeWorksheet = ActiveSheet
curRow = 1
For Each ws In ActiveWorkbook.Worksheets
If Not ws.Name = activeWorksheet.Name Then
ws.Range("A293:AL293").Copy Destination:=activeWorksheet.Range(CStr(curRow) & ":" & CStr(curRow + 288))
curRow = curRow + 289
End If
Next ws
End Sub
我发现的另一个代码是:
Option Explicit
Sub CreateTempPSDReport()
Dim WS As Worksheet, Rept As Worksheet
Set Rept = Sheets("Temporary PSD Report")
Application.ScreenUpdating = False
'--> Loop through each worksheet except the report and
'--> Copy the set range to the report
For Each WS In ThisWorkbook.Worksheets
If Not WS.Name = "Temporary PSD Report" Then
WS.Range("A42", "I42").Rows.Copy
Rept.Cells(Rows.Count, "A").End(xlUp).Offset(1, 0).PasteSpecial _
Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
End If
Next
Application.ScreenUpdating = True
End Sub
但我不确定是什么
WS.Range("A42", "I42").Rows.Copy
Rept.Cells(Rows.Count, "A").End(xlUp).Offset(1, 0).PasteSpecial _
Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
部分可以。
谢谢!