Skip to content


Tech Tuesday: Working with values in Excel with VBA

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

Leave a Comment


Join Us in Chicago at the Zendesk Showcase!
Tech Tuesday: Popdock - Joining the tale of two States
Meet eOne Solutions at Directions EMEA 2023!
Connect with eOne Solutions at SuiteWorld 2023!
What is a Data Lake/Data Lake Management?


2016 SmartConnect Integration Bootcamps
Tech Tues: Automatically refreshing Pivot Tables in Excel Refreshable Reports
Happy Thanksgiving from the eOne team!
2017 SmartConnect Integration Bootcamps
New Releases of Extender and SmartList Builder



Business Central CRM D365 Business Central Dynamics 365 dynamics crm Dynamics GP Dynamics NAV Econnect Employee Spotlight eone eOne News error Error Message Events Excel Excel Report Builder Extender Flexicoder GP integration Map Microsoft dynamics crm Microsoft Dynamics GP Navigation List Builder Office Relationships Partner All Hands Call Popdock promotions release Salesforce SmartConnect SmartConnect Bootcamp SmartConnect Maps SmartConnect Office Hours SmartList SmartList Builder SmartPost SmartView SQL Tech Tuesday Templates training Zendesk

Integrate & Automate without Any Code.

SmartList Data has Never Been Faster.

The Easiest Way to Report on GP Data.