特定の日と食事に摂取した食品を記録するのに役立つエクセルがあります。私は、各行があなたが食べた食べ物、砂糖の量などを表すグリッドを持っています.
次に、すべてのデータを別のシートのテーブルに保存するための保存ボタンを追加しました。
これは私が試したものです
Public Sub addDataToTable(ByVal strTableName As String, ByRef arrData As Variant)
Dim lLastRow As Long
Dim iHeader As Integer
Dim iCount As Integer
With Worksheets(4).ListObjects(strTableName)
'find the last row of the list
lLastRow = Worksheets(4).ListObjects(strTableName).ListRows.Count
'shift from an extra row if list has header
If .Sort.Header = xlYes Then
iHeader = 1
Else
iHeader = 0
End If
End With
'Cycle the array to add each value
For iCount = LBound(arrData) To UBound(arrData)
**Worksheets(4).Cells(lLastRow + 1, iCount).Value = arrData(iCount)**
Next iCount
End Sub
しかし、強調表示された行で同じエラーが発生し続けます:
Application-defined or object-defined error
私は何を間違っていますか?
前もって感謝します!