VBA InputBox错误

时间:2016-10-25 19:20:24

标签: excel vba

我正在尝试让我的输入框将数字转储到特定的单元格中。我已经让它工作到提示正确单元格上的框,但是当我按Enter键或单击确定时单元格保持空白。 有没有人知道如何解决?

谢谢!

    Sub DiscardPipe()        
    Dim str As String
    Dim rtrn As String
    Dim impu As Integer
       With Worksheets(ActiveSheet.Name)
       rtrn = ActiveSheet.Name
       str = Range("e2").Value

    Set SrchRng = Worksheets("Information").Range("J8:J17").Find(what:=str)
     Sheets("information").Select
     Range("J8:J17").Find(what:=str).Select
     Selection.End(xlToRight).Select
       Selection.End(xlToRight).Select
        Selection.End(xlToRight).Select
        Selection.End(xlToRight).Select
        Selection.End(xlToRight).Select
        Selection.End(xlToRight).Select
        Selection.End(xlToRight).Select
        Selection.End(xlToRight).Select
        Selection.End(xlToRight).Select
        Selection.End(xlToRight).Select
        Selection.End(xlToRight).Select
        Selection.End(xlToLeft).Select
        ActiveCell.Offset(0, 1).Range("A1").Select
      impu = InputBox("Enter New Bottom Pipe Serial Number", "New Pipe", 1)

        End With
    End Sub 

1 个答案:

答案 0 :(得分:0)

在输入框中添加数字后,以下内容仍然留有空白单元格     Sub DiscardPipe()         Dim str As String         Dim rtrn As String         Dim impu As Integer

       With Worksheets(ActiveSheet.Name)
       rtrn = ActiveSheet.Name
        str = Range("e2").Value
        End With
    Set SrchRng = Worksheets("Information").Range("J8:J17").Find(what:=str)
     Sheets("information").Select
     Range("J8:J17").Find(what:=str).Select
     Selection.End(xlToRight).Select
       Selection.End(xlToRight).Select
        Selection.End(xlToRight).Select
        Selection.End(xlToRight).Select
        Selection.End(xlToRight).Select
        Selection.End(xlToRight).Select
        Selection.End(xlToRight).Select
        Selection.End(xlToRight).Select
        Selection.End(xlToRight).Select
        Selection.End(xlToRight).Select
        Selection.End(xlToRight).Select
        Selection.End(xlToLeft).Select
        ActiveCell.Offset(0, 1).Range("A1").Select
        impu = InputBox("Enter New Bottom Pipe Serial Number", "New Pipe", 8)
        Range("A1").Value = impu
    End Sub