title: Trying to use an input box in excel vba
body: <p>I'm trying to get values to use in my code using an input box but it starts giving me bugs when I add this in.</p>
  
  <pre><code>Sub pipe_size()
  
  Dim x As Variant
  Dim y As Variant
  Dim NPS As Variant
  Dim Sch As Variant
  Dim z As Single
  Dim i As Single
  Dim a As Variant
  Dim j As Integer
  Dim msg As String
  Dim b As Variant
  
  'NPS = InputBox("Enter Nominal Pipe Size(inches)", "Nominal Pipe Size")
  'Sch = InputBox("Enter Schedule Number", "Pipe Schedule")
  
  NPS = Worksheets("Sheet2").Range("R35").Value
  Sch = Worksheets("Sheet2").Range("R36").Value
  'x is column number, y is row number
  x = Application.WorksheetFunction.Match(NPS, Worksheets("Sheet2").Range("Q5:Q33"), 0)
  y = Application.WorksheetFunction.Match(Sch, Worksheets("Sheet2").Range("R3:AD3"), 0)
  
  'Worksheets("Sheet2").Range("Y34").Value = Sch
  'Worksheets("Sheet2").Range("Y35").Value = x
  'Worksheets("Sheet2").Range("Y36").Value = y
  
  Worksheets("Sheet2").Range("AI1:AI13").Clear
  Worksheets("Sheet1").Range("E4").Clear
  
  For i = 1 To 13
  a = Application.WorksheetFunction.Index(Worksheets("Sheet2").Range("R5:AD33"), x, i)
  If a &gt; 0 Then
  Worksheets("Sheet2").Range("AI" &amp; i).Value = Application.WorksheetFunction.Index(Worksheets("Sheet2").Range("R3:AD33"), 1, i)
  Else: End If
  Next i
  
  z = Application.WorksheetFunction.Index(Worksheets("Sheet2").Range("R5:AD33"), x, y)
  If z &gt; 0 Then
  Worksheets("Sheet2").Range("Y37").Value = z
  Worksheets("Sheet1").Range("E4").Value = z
  ElseIf z = 0 Then
  MsgBox ("This pipe schedule does not exist for this pipe size")
  msg = "The following schedules exist for this pipe size:" &amp; vbCrLf
  
  For j = 1 To 13
  b = Worksheets("Sheet2").Range("AI" &amp; j)
  If b &gt; 0 Then
  msg = msg &amp; vbCrLf &amp; b
  
  Else: End If
  
  Next j
  
  MsgBox msg
  
  Else: End If
  
  
  End Sub
  </code></pre>
  
  <p>The code runs fine when it gets the values for NPS and Sch from a  cell but  when I try to use an input box to give the values, it finds type mismatches and errors in the workbookfunctions.</p>