I wrote VBA code that reads through a simple text file containing comma separated values and assigns these values to an array. Each array value then gets assigned to a cell on an Excel worksheet. Relevant lines of code are as follows:
Dim arySingle(826) As Single
Dim sht As Worksheet
Set sht = ActiveWorkbook.Sheets("Input Form")
... various lines of code...
sht.Range("STLI").Value = arySingle(654)
... code continues on...
Note: "Input Form" is the only worksheet in the workbook.
The value read in from the text file is .06. I have verified this both by looking at the text file contents and by breaking the code on the VBA line above and tested the value of arySingle(654)
in the Immediate window. No other line of code affects the named range "STLI".
The named range (single cell) "STLI" is formatted as a two decimal percentage cell. After the VBA code runs, the cell shows 6.00%, but when selected, it shows a value of 5.99999986588954% in the formula bar. I do have other cells similarly formatted, and when a value is passed to them, they also show a value other than the value passed by the VBA code.
What would be causing this? What is the solution?
Thank you for your help.