Changing number of decimals in WRITEEXCEL function
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Changing number of decimals in WRITEEXCEL function
Hi,
I am writing a large matrix to excel and I try to change the number of decimals it is writing to excel.
I use the WRITEEXCEL function.
Is is possible to change the number of decimals before writing to excel?
Thanks in advance!
Solved! Go to Solution.
- Labels:
-
Programming
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
As for the poster's original question, you still need to round/truncate the "extra" decimal points using a formula. However, this is a simple formula of =ROUND(,) that is not extremely computationally expensive Prepaid Card Status.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi,
Yes it is possible to use the "round()" function on a matrix of numbers before the writing to excel.
With no round statement.
With the round function.
Cheers
Terry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hello terryhendicott,
Thanks a lot for your help. So in order to round a large matrix, I have to use some for loops to go through that matrix.
Looking at your example I still see that 15 decimals are exported to excel... A solution for this is to set the cell format in excel to 2 decimals for example, but then I have to perform this action every time I have exported data from Mathcad.
Is is possible to only send two decimal values to excel?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi,
"So in order to round a large matrix, I have to use some for loops to go through that matrix. "
Yes the round function can be applied to a vector all at once so you loop through the columns of the matrix.
"Looking at your example I still see that 15 decimals are exported to excel... A solution for this is to set the cell format in excel to 2 decimals for example, but then I have to perform this action every time I have exported data from Mathcad.
Is is possible to only send two decimal values to excel?"
It does only send two decimals to excel. I formatted excel to show 15 decimal places.
This is how excel shows without formatting straight after transfer.
Cheers
Terry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Why not vectorize?
Success!
Luc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
As for the poster's original question, you still need to round/truncate the "extra" decimal points using a formula. However, this is a simple formula of =ROUND(,) that is not extremely computationally expensive Prepaid Card Status.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
There should be no need to use the ROUND function within excel. You can just set the number of displayed decimals in the number formatting section of excel:
Success!
Luc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi Luc,
Thanks for you answer.
That method doesn't work, since Mathcad is overwriting the cell format in excel.
The round function does work:)
