我有VBA程序,允许用户在活动Excel工作表的第一行输入名称(整数/字符串/等)来编写 Headers . 写入输入后,我需要在相邻的单元格中写入输出 .
逐行逐行,我相信这是产生错误的问题行
运行时错误13:输入不匹配
Cells(1, counter + inputnum) = outputnum
这是相关的功能:
Sub enteroutputs()
title = "K-Map Program"
outputnum = Application.InputBox("How many outputs?", title)
If IsNumeric(outputnum) = False Then
problem = "output"
Call notnum
End If
For counter = 1 To outputnum
outputnum = Application.InputBox("Enter output name.", title)
Cells(1, counter + inputnum) = outputnum
Next
Dim ok
ok = MsgBox("Enter outputs in " & ActiveSheet.Name & " .", vbOKOnly)
End Sub
inputnum在此函数之前执行的函数中定义:
Sub enterinputs()
title = "K-Map Program"
inputnum = Application.InputBox("How many inputs?", title)
If IsNumeric(inputnum) = False Then
problem = "input"
Call notnum
End If
For counter = 1 To inputnum
inputnum = Application.InputBox("Enter input name.", title)
Cells(1, counter) = inputnum
Next
Call enteroutputs
结束子