I am reading a file with currency values and creating strings of data to print into a text file. I discovered that I needed to use the VALUE2 option in order to stop the macro from rounding the values. However, I have now run into the problem that if any of the trailing digits are zeros, they are dropped. I need the macro to keep all digits.
For example, if the cell has $10.50 formatted as currency, the code below reads 10.5 into payAmountTemp, but I need 10.50.
payAmountTemp = Cells(j, 5).Value2
What would be the best way to go about capturing the data correctly? Just FYI, I must then further format the data for the text file for a 7 digit field with no decimal and with leading zeros, so I am using the code below next.
payAmount = String(7 - Len(Replace(payAmountTemp, ".", "")), "0") & Replace(payAmountTemp, ".", "")
In the example above, I am getting 0000105 where I need 0001050.