获取Excel Vba运行时错误1004

时间:2018-03-15 13:11:10

标签: vba excel-vba excel

Private Sub CommandButton3_Click()
    Dim rownum, startcol, endcol, holder As Integer
    rownum = InputBox("Enter the row that swapping process going to happen")
    startcol = InputBox("Enter the column of the cell you want to swap")
    endcol = InputBox("Enter the column of the cell that you wanted swap with")
    holder = Cells(rownum, startcol).Value
    Cells(rownum, startcol).Value = Cells(rownum, endcol).Value
    Cells(rownum, endcol).Value = holder
End Sub

给予

  

运行时错误1004 - “运行时错误'1004':                       应用程序定义或对象定义的错误“

似乎无法理解。

1 个答案:

答案 0 :(得分:2)

正确调暗你的变量并使用application.inputbox获取更多选项。

type:=1

type:=2告诉application.inputbox预期一个数字; var str = '{"taskStatus":"Failed","taskFields":{"originalTransactionDate":"2017-08-17","transactionPostingDate":"2017-08-17","referenceNumber":"12345","promotionIdentifier":"undefined","merchantAdjustmentDescription":"test","transactionAmount":"150.00","batchPrefix":"IF","transactionCode":"Failed6"}}'; str = JSON.parse(str); document.write(JSON.stringify(str));告诉application.inputbox期望一个字符串。

相关问题