Recently the eOne team was working on releasing some new Excel templates for SmartConnect and ran across a unique issue. In the General Ledger template we have code that compares the Sum of the Debits and Credits to ensure they match before submitting the transaction to Dynamics GP. What we were finding was that even though it displayed the same on the screen it was still returning a message that the Debits didn’t match the Credits.

After a bit of research it became apparent that we were checking the Text of the Cell in the Worksheet instead of the Value. What does this mean exactly, let me explain how Excel evaluates Cell values.

In the picture below you can see that I have the value 211808.11 selected. In the next picture you can see I decreased the size of the column and now only one decimal is visible.


If we run a simple VBA script to display the value returned from the column that is reduced in size we get the following result:

MsgBox (Sheets(“Sheet1”).Cells(22,9).Text)

     Returns: 211808.1

If we return the Value instead of the Text using the script below you will get a different value:

MsgBox (Sheets(“Sheet1”).Cells(22,9).Value)

     Returns: 211808.11

Additionally, there is a third way to get the value in Excel using VBA called Value2. This is the most accurate way of getting the data you want because it gives you the original value (with no formatting and all the decimal places if copied).

MsgBox (Sheets(“Sheet1”).Cells(22,9).Value2)

The point of this story is simply this, if you want the formatted value the way it appears, use .Text, if you want the full value of that cell, use .Value, if you want the completely raw information use .Value2.

My recommendation is to use the .Value or .Value2 as it will return the data that is desired for most applications.

After switching the little piece of code to use .Value in our templates we now have a great template that correctly balances the Debits and Credits even with very large numbers.

Hope this helps someone else as I spent a few hours on this issue.

Chris Dew
Director of Product Management