Forums
New posts
Search forums
What's new
New posts
New media
New media comments
Latest activity
Media
New media
New comments
Search media
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Main Forums
Automation, Cinema, Computers, Television Forum
Extractor integer and mantissa parts
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Help Support Talk Electrician Forum:
This site may earn a commission from merchant affiliate links, including eBay, Amazon, and others.
Message
<blockquote data-quote="wabbitwabbit" data-source="post: 2708"><p>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.</p><p></p><p>For example CalcValue = 5678.96</p><p></p><p>By extraction -</p><p></p><p>LenIs = Len(CalcValue)</p><p></p><p>DecLoc = InStr(1, CalcValue, ".")</p><p></p><p>ValBox1 = Left(CalcValue, DecLoc - 1)</p><p></p><p>Sheets("Form").Range("FormBox1") = ValBox1 'Display integer only</p><p></p><p>P = Mid(CalcValue, DecLoc + 1, 2)</p><p></p><p>LenP = Len(P)</p><p></p><p>If LenP = 1 Then P = P &amp; "0" ' I want trainling zeropsd to be literally displayed</p><p></p><p>Sheets("Form").Range("FormBox1P") = P</p><p></p><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.</p><p></p><p>Cheers</p></blockquote><p></p>
[QUOTE="wabbitwabbit, post: 2708"] 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 [/QUOTE]
Insert quotes…
Verification
Post reply
Main Forums
Automation, Cinema, Computers, Television Forum
Extractor integer and mantissa parts
Top