次のコード行では、変数範囲 (列 U) を合計しようとしています。私のコード内で何が間違っているのか教えてください(助けていただければ幸いです):
問題のあるコード行:
Sheets(gcsReportSheetName).Cells(LCounter, 3).FormulaR1C1 = "=sum(" & rng.Value & "!" & Lsumcolumn & ":" & Lsumcolumn & ")"
完全なコード。
Sub Report()
Dim rng As Range
Dim LCounter As Long
Dim sLsheet As String
Dim Lsumcolumn As Long
Set gRwksconfigeration = Sheets("Config")
Set gRnct_Funds_2 = gRwksconfigeration.Range(CT_Funds_2)
LCounter = 3
For Each rng In gRnct_Funds_2
Sheets(gcsReportSheetName).Cells(LCounter, 1) = rng.Value
If rng.Value = "" Then
Exit Sub
Else
Sheets(gcsReportSheetName).Cells(LCounter, 2) = Sheets(rng.Value).Cells.Find(What:="Value", After:=Cells(1, 1), LookIn:=xlValues, LookAt:= _
xlWhole, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).End(xlDown).Value
Lsumcolumn = Sheets(rng.Value).Cells.Find(What:="illiquid check", After:=Cells(1, 1), LookIn:=xlValues, LookAt:= _
xlWhole, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Column
Sheets(gcsReportSheetName).Cells(LCounter, 3).FormulaR1C1 = "=sum(" & rng.Value & "!" & Lsumcolumn & ":" & Lsumcolumn & ")"
LCounter = LCounter + 1
End If
Next
End Sub