【发布时间】:2015-07-10 13:25:46
【问题描述】:
这是第一次在 Excel 中使用 VBA。我正在练习使用公式并使用 Excel 单元格和 MsgBoxes 显示值。
我当前的问题很可能是一个简单的解决方案,但尚未解决。
我想让我的 MsgBox 在填充每一行后显示以下内容:
味精弹出
Socks Gross Sale is 56.37
味精弹出
Lotion Gross Sale is 59.12
..etc
但是,当我第一次尝试运行注释掉的代码行 MsgBox Range("A14:A21").Value & " Gross Sale is " & Range("F14:F21").Value 时,它会给出错误 Run-time error '13': Type mismatch,所以它不起作用。
因此,到目前为止,我正在使用我的代码行 MsgBox Range("A14:A21").Value & " Gross Sale is " & Range("F14:F21").Value
,它只通过循环连续填充 Sock 行。有什么建议吗?
For Each Cell In Worksheets("Sheet1").Range("B14:E21").Cells
Range("F14:F21").Formula = "=SUM((B14*D14)-((B14*D14)*E14))"
'MsgBox Range("A14:A21").Value & " Gross Sale is " & Range("F14:F21").Value
'Gives me first line only and makes pop up show twice as many times as (all)total rows
MsgBox Range("A14").Value & " Gross Sale is " & Range("F14").Value
Next
【问题讨论】: