W
wabbitwabbit
Guest
Using VBA within Excel and having calculated an amount, which can be any value up to 2,000,000.00 I now want to extract the integrer pounds value, that is quite easy BUT extracting to the right of the decimal place is less easy.
For example CalcValue = 5678.96
By extraction -
LenIs = Len(CalcValue)
DecLoc = InStr(1, CalcValue, ".")
ValBox1 = Left(CalcValue, DecLoc - 1)
Sheets("Form").Range("FormBox1") = ValBox1 'Display integer only
P = Mid(CalcValue, DecLoc + 1, 2)
LenP = Len(P)
If LenP = 1 Then P = P & "0" ' I want trainling zeropsd to be literally displayed
Sheets("Form").Range("FormBox1P") = P
There HAS to be an easier way, any VBA blokes on here can help. All I am actually doing is automating a VAT Return form and having derived all the values for all boxes on a VAR Return want to plug the values into a template sheet such that the form as sent by the VAT office can be put through the printer.
Cheers
For example CalcValue = 5678.96
By extraction -
LenIs = Len(CalcValue)
DecLoc = InStr(1, CalcValue, ".")
ValBox1 = Left(CalcValue, DecLoc - 1)
Sheets("Form").Range("FormBox1") = ValBox1 'Display integer only
P = Mid(CalcValue, DecLoc + 1, 2)
LenP = Len(P)
If LenP = 1 Then P = P & "0" ' I want trainling zeropsd to be literally displayed
Sheets("Form").Range("FormBox1P") = P
There HAS to be an easier way, any VBA blokes on here can help. All I am actually doing is automating a VAT Return form and having derived all the values for all boxes on a VAR Return want to plug the values into a template sheet such that the form as sent by the VAT office can be put through the printer.
Cheers