首页 > 解决方案 > 尽管通过 VBA 打开代码,但仍然遇到“编译错误:找不到方法或数据成员”

问题描述

当我尝试运行我的代码时,我一直遇到编译错误。即使我通过双击按钮拉出代码并自动填充它,它仍然突出显示第一行。如果有什么我完全想念的,请告诉我。

Private Sub SubmitButton1_Click() **this is the line it is highlighting and showing an error for**

Dim emptyRow As Long

'Make Fridge Inventory sheet active
FridgeInventory.Activate

'Determine emptyRow
emptyRow = WorksheetFunction.CountA(Range("A:A")) + 1

'Transfer information
Cells(emptyRow, 1).Value = Item.Value
Cells(emptyRow, 2).Value = Amount.Value
Cells(emptyRow, 3).Value = unit.Value
Cells(emptyRow, 4).Value = Quantity.Value

End Sub

cmdButton 的名称与代码行中的名称相同

额外帮助的代码图片

标签: excelvbacompiler-errors

解决方案


推荐阅读