我有一张原始数据表,其平均值位于底部,我想遍历摘要表中的每一列,并将给出的平均值放在下面的原始数据表中。 我所拥有的:
On Error Resume Next
Application.DisplayAlerts = False
Sheets.Add After:=Worksheets("Raw PivotTable")
ActiveSheet.Name = "Summary"
Application.DisplayAlerts = True
Set SSheet = Worksheets("Summary")
Set RSheet = Worksheets("Raw PivotTable")
Set PSheet = Worksheets("PivotTable")
Dim C As Integer
Dim PSheetVal As Long
C = 2
RSheet.Range("B1:" & ActiveSheet.Range(Cells(1, Columns.Count).End(xlToRight).Address).End(xlUp).Address).Copy
ActiveSheet.Paste Destination:=SSheet.Range("A1")
For Each cell In SSheet.Range("A1:" & SSheet.Range("A1").End(xlToRight).Address)
PSheetVal = PSheet.Range(Cells(2, C)).End(xlDown).Value
' ^^^^ this is causing my issues specifically.
cell.Offset(1, 0).Value = PSheetVal
C = C + 1
Next
对我来说,它是用0代替实际值。
答案 0 :(得分:0)
代替复制粘贴,您可以执行以下操作:
useEffect(() => {})
if (context.token) {
return <Redirect to="/" />;
}
答案 1 :(得分:-1)
我已解决问题!我没有选择确切的单元格,而是选择了整个列,然后选择了最后一个单元格。我的代码:
For Each cell In SSheet.Range("A1:" & SSheet.Range("A1").End(xlToRight).Address)
With Sheets(PSheet)
PSheetVal = PSheet.Columns(C).End(xlDown).Value
End With
With Sheets(SSheet)
cell.Offset(1, 0).Value = PSheetVal
End With
C = C + 1
Next
仍然不太确定如何选择一个非常特定的单元格,但是出于我的目的,如果有人可以为我指明正确的方向,这将很有帮助!