title: Can't convert string to an integer in VBA or by Excel formulas (failure to convert or wrong number even if string is all numeric)
body: <p>I have a string inside a cell: 105501008962100001</p>
  
  <p>Cell A10 contains this text.</p>
  
  <p>When I run ISTEXT(A10) it returns TRUE.</p>
  
  <p>I used VALUE(A10) but it returned 105501008962100000</p>
  
  <p>When I multiply A10 * 1, I get 105501008962100000 as well.</p>
  
  <p>I have also created a VBA function to convert to integer but when I create checkpoints, it creates an error saying that there is a failure to convert to integer.</p>
  
  <p>I do not understand why I cannot convert this string inside this cell to an integer when it is composed entirely of numbers. This number is imported from a CSV file.</p>
  
  <pre><code>Function ConvertToInteger(v1 As Variant) As Integer
  On Error GoTo 100:
  
      'MsgBox Len(v1)
  
      Dim tempArray As Variant
      Dim arraySize As Integer
      arraySize = (Len(v1) - 1)
      ReDim tempArray(arraySize)
  
      Dim tempText As String
      Dim finalNumber As Integer
      Dim i As Integer
  
      For i = 1 To Len(v1)
          tempArray(i - 1) = CStr(Mid(v1, i, 1))
      Next
  
      tempText = Join(tempArray, "")
      tempText = CStr(tempText)
  
      'MsgBox tempText
  
       finalNumber = CInt(tempText)
  
       MsgBox finalNumber
  
      'ConvertToInteger = finalNumber
  
  Exit Function
  100:
      MsgBox "Failed to convert """ &amp; v1 &amp; """ to an integer.", , "Aborting - Failed Conversion"
      End
  End Function
  </code></pre>
  
  <p>I made modifications to the code but still get the 0 at the end not 1 in the number:</p>
  
  <pre><code>Function ConvertToInteger(v1 As Variant) As Double
  
      Dim tempArray As Variant
      Dim arraySize As Double
      arraySize = (Len(v1) - 1)
      ReDim tempArray(arraySize)
  
      Dim tempText As String
      Dim finalNumber As Double
      Dim i As Integer
  
      For i = 1 To Len(v1)
          tempArray(i - 1) = CStr(Mid(v1, i, 1))
      Next
  
      tempText = Join(tempArray, "")
      tempText = CStr(tempText)
  
      finalNumber = CDbl(tempText)
  
      MsgBox finalNumber
  
      'I get an error here when assigning finalNumber to ConvertToInteger
      'ConvertToInteger = finalNumber
  
  End Function
  </code></pre>