【问题标题】:Object doesn't support this property or method?对象不支持此属性或方法?
【发布时间】:2025-11-27 14:55:02
【问题描述】:

我正在尝试在 Excel 中输入字母成绩,但是当我输入成绩时,它会出现“错误 428,对象不支持此属性或方法”。我做错了什么?

Option Explicit
Sub HW09()

Dim ng As Integer
Dim v As String

Do

ng = InputBox("Please enter the student's numerical grade.")
    If ng < 0 Then
        ng = 0
    ElseIf ng > 100 Then
        ng = 100
    Else
End If


Cells(c, 2).Value (ng)
c = c + 1

v = InputBox("Would you like to enter another grade? Type 'Y' for yes and 'N' for no.")
    If v = "N" Then Exit Do

Loop

【问题讨论】:

  • @sam092 有答案。我注意到这个in your previous question 并确保我的回答避免了这个错误。此外,您可以简单地做:If MsgBox("Would you like to enter another grade?", vbYesNo) = vbNo Then Exit Do 而不是依赖InputBox 和笨重的字母/字符串用户输入:)

标签: excel vba


【解决方案1】:

应该是

Cells(c, 2).Value = ng

如果您输入 A,B,C 之类的字母,则应该得到 Type Mismatch Error

另外,我没有看到 c 的任何初始化

【讨论】:

    最近更新 更多