title: Variable isn't set unless debug.print executed first
body: <p>On my sheet, I click a button, the button fires the below Sub. Which is supposed to read the row and col of the clicked button location, then pop up a message box the with the content of a hidden cell on the same row.</p>
  
  <p>When this code executes, the <code>ipf</code> variable always remains as the string "initial" unless I add a <code>debug.print</code> statement. I can debug.print any of the variables (<code>ipf</code>, <code>row_no</code>, <code>col_no</code>) and the <code>ipf</code> variable is set fine.</p>
  
  <p>After I've added debug.print, clicked the relevant button to get the right result, then removed debug.print, it continues to work until I reload the sheet.</p>
  
  <p>I've tried casting as a string in case that is the problem, but I simply do not understand why it's doing this.</p>
  
  <p>Essentially, the sheet is filled with up to three buttons on each row, when one of those buttons is clicked, this code grabs the row and col of the clicked button to pull the value of the cell, which will be one of three strings; "Initial", "Prelim" or "Final". Using that string (in the <code>ipf</code> variable) it will fall into one of the cases to pull a string from another cell on that row to show in a message box.</p>
  
  <p>Unless the <code>debug.print</code> is there, the <code>ipf</code> var is <em>always</em> "Initial".</p>
  
  <pre class="lang-vb prettyprint-override"><code>Public Sub showDefinitionMsgBox()
      Dim obj As Object, _
          row_no As Long, _
          col_no As Long, _
          wsMain As Worksheet 'This is the worksheet were using
  
      ' Get the row and column of the clicked button
      Set obj = ActiveSheet.Buttons(Application.Caller)
      row_no = obj.TopLeftCell.row
      col_no = obj.TopLeftCell.column
  
      ' Grab the name (e.g. INitial, Prelim, Final)
      ' When a button is clicked, we pull the value from the cell under the button.
      ' It will be either "Initial", "Prelim" or "Final"
      Set wsMain = ActiveWorkbook.Sheets("MainSheet")
      Dim ipf As String
      ipf = CStr(wsMain.Cells(row_no, col_no).Value)
  
      ' Get the element name
      ' This simply get's a string, which is the name of the row
      Dim element As String
      element = wsMain.Cells(row_no, 12).Value
  
      ' Withouth this, ipf is _always_ "initial"
      Debug.Print ipf
  
      ' Pull the text from the dictionary
      ' 13 = init, 14 = prelim, 15 = final
      ' Using the above ipf variable, set the message text as the content
      ' of another cell in the wsMain sheet.
      Dim message As String
      Select Case ipf
          Case "Initial":
              message = wsMain.Cells(row_no, 13).Value
          Case "Prelim":
              message = wsMain.Cells(row_no, 14).Value
          Case "Final":
              message = wsMain.Cells(row_no, 15).Value
          Case Else
              message = "Cannot find that element type:"
      End Select
  
  
      ' Show the message box
      ' @TODO: Update this to UserForm for more space
      MsgBox message, vbOKOnly, element
  End Sub
  </code></pre>
  
  <p>I expect the value from the correct cell to appear in the msgbox, but I always get the value from the first case, unless I add the debug.print line.</p>