文字列を変数として関数に渡そうとしましたが、配列の値を値と比較しようとすると、'424オブジェクトが必要'のエラーが発生します。与えられたセルで。私はVBAの初心者ですので、これは単純な構文エラーかもしれませんが、わかりません。ここに私のコードは次のとおりです。呼ばれてVBA Excelオブジェクトは、文字列配列変数を渡す必要があります
方法:
Sub InitializeCharts()
'Set's up the array for checking data names in the social groups
Dim socialArray As Variant
socialArray = Array("Chores", "Meat & Potatos", "Work", "Wind Down", "Reward")
'...
Call ChartLogic(Range("'ActivityTracker'!B12"), Range("'Groups'!F4"), socialArray)
End Sub
ChartLogic方法:事前に
Sub ChartLogic(dataCell As Range, tableCell As Range, socialArray As Variant)
Dim temp As Double
Dim count As Integer
'...
'Loops through the table and looks for the social cells with the same name, adding them to the chart
Do Until IsEmpty(dataCell)
For count = LBound(socialArray) To UBound(socialArray)
If socialArray(count).Value = dataCell.Value Then '<---Error Here
temp = socialCell.Offset(count, 0).Value
socialCell.Offset(count, 0).Value = temp + dataCell.Offset(0, 4).Value
End If
Next
Set dataCell = dataCell.Offset(1, 0)
Loop
End Sub
ありがとう! socialArray(count)
プロパティValue
を持つオブジェクトを生成しないので、
一度あなたがそれを指摘したら明らかになりそうです! – newguy