I have a User Form where I ask the user to input a number. This number then gets input into several cells across a few difference sheets.
Ultimately the number will be stored in the cells as a percentage, and I have already formatted the cells to hold a percentage with 2 decimal places. So, when my code inserts the number into the cell, the number must be a decimal number to the 4th decimal place. (For instance, if the user inputs '21.59', my code converts it to '.2159' before writing it into the proper cell.
Here is the code that runs when the user clicks a button on the User Form, after they have entered their number.
If the user inputs '21.59' as their number, this code seems to work. In Cell AN33, '21.59%' appears. HOWEVER, what appears in the formula bar when Cell AN33 is highlighted is '21.5900003910064%'
I don't understand why this is. Any ideas?
Perhaps this is not something to worry about -- maybe it will not affect the math that is going to be done on the sheet using this percentage. But just in case it is, I would really love for the number that appears in the cell to truly only have two decimal places. I'm certainly open to another way to go about the whole thing if it will solve the problem. TIA!
Ultimately the number will be stored in the cells as a percentage, and I have already formatted the cells to hold a percentage with 2 decimal places. So, when my code inserts the number into the cell, the number must be a decimal number to the 4th decimal place. (For instance, if the user inputs '21.59', my code converts it to '.2159' before writing it into the proper cell.
Here is the code that runs when the user clicks a button on the User Form, after they have entered their number.
Code:
Private Sub MarkupApplyButton_Click()
Dim ConvertedValue As Single
ConvertedValue = Round(MarkupTextBox.Value / 100, 4)
Sheets("Cost Summary").Range("AN33").Value = ConvertedValue
End Sub
If the user inputs '21.59' as their number, this code seems to work. In Cell AN33, '21.59%' appears. HOWEVER, what appears in the formula bar when Cell AN33 is highlighted is '21.5900003910064%'
I don't understand why this is. Any ideas?
Perhaps this is not something to worry about -- maybe it will not affect the math that is going to be done on the sheet using this percentage. But just in case it is, I would really love for the number that appears in the cell to truly only have two decimal places. I'm certainly open to another way to go about the whole thing if it will solve the problem. TIA!