【问题标题】:VBA - Input box - userformVBA - 输入框 - 用户窗体
【发布时间】:2017-11-24 05:54:13
【问题描述】:

这是我的代码:

qty = InputBox("Please enter the quantity to be added.", "Add Quantity")
Cells(row, 2) = qty
Description = InputBox("Please enter a description.", "Enter Description")
Cells(row, 3) = Description
Unitp = InputBox("Please enter a unit price.", "Enter UnitPrice")
Cells(row, 4) = Unitp
Amount = InputBox("Please enter an amount.", "Enter Amount")
Cells(row, 5) = Amount

Qty & Unitp 在 Excel 中正确显示。但是,当我在 Description 输入框中输入字符时,它会引发错误。但是如果我输入no。它通过但在 Excel 单元格中显示为FALSEDescriptonAmount 都是这种情况。

有人可以帮忙吗?

【问题讨论】:

  • Description 是如何定义的?
  • 你写Dim Description As Bool左右吗?

标签: excel inputbox vba


【解决方案1】:

您需要声明您的变量以便它们接受正确的输入,将其放在您的代码上方:

Dim qty as Integer
Dim Unitp as Double
Dim Description as String
Dim Amount as Integer

【讨论】:

    【解决方案2】:

    此问题已解决。我已经为其他一些变量声明了描述。只需将其从 Description 更改为 Desc 以及类似的金额字段。

    工作得很好。

    感谢你们的帮助!

    【讨论】:

      猜你喜欢
      • 2018-12-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-02-09
      • 1970-01-01
      • 2010-10-07
      相关资源
      最近更新 更多