logo
search
VBA & Macro Problems

How to Import a Tally Trial Balance into Excel using VBA

Steve KSteve K Oct 1, 2026 869 views

Question details

The user is looking for an Excel VBA code solution to automate the importation of a trial balance directly from Tally accounting software.

How to Import a Tally Trial Balance into Excel via VBA Code
Product
Microsoft Excel
Device & OS
not provided
Scenario
Automating the extraction and formatting of financial data from Tally to a spreadsheet for easier analysis and reporting.
Observed behavior
The user needs a specific VBA script or guidance on establishing a data connection between Excel and Tally to pull trial balance records.
Before you start

Ensure that your Tally software is open and configured to allow ODBC connections, and that the Developer tab is enabled in your spreadsheet software so you can access the VBA editor.

Solution 1Recommended

Use ODBC Connection via VBA to Query Tally Data

The standard programmatic way to extract Tally data into Excel is by establishing an ADODB connection via Tally's built-in ODBC server.

Tally acts as a database server when its ODBC feature is enabled. You can use standard ADODB connection strings in VBA to query Tally Definition Language (TDL) tables, such as the Trial Balance, directly into your worksheet.

1
Enable Tally ODBC

Open Tally, go to the Configuration or Settings menu, and ensure the ODBC server is enabled. Take note of the port number (default is usually 9000).

2
Open the VBA Editor

In Excel, press Alt + F11 to open the Visual Basic for Applications (VBA) editor. Click 'Insert' and select 'Module' to create a new blank script.

3
Write the ADODB Connection Script

Write a VBA sub-routine using 'CreateObject("ADODB.Connection")'. Set the connection string to point to the Tally ODBC driver, formatted as 'Driver={Tally ODBC Driver}; DB=TallyData; Port=9000;'.

4
Execute SQL Query

Use a Recordset object to pass an SQL query (e.g., 'SELECT * FROM TrialBalance') through the connection, and then use 'CopyFromRecordset' to output the fetched financial data into your desired worksheet cells.

Use ODBC Connection via VBA to Query Tally Data
Understanding TDL Queries: Because Tally's internal database structure is complex, writing the exact SQL query may require a strong understanding of Tally Definition Language (TDL) and the specific XML tags Tally uses.
Free Microsoft Office alternative

Analyze Tally Trial Balances with WPS Office

Need a fast, reliable, and lightweight spreadsheet tool for your accounting needs? WPS Office provides excellent compatibility with Microsoft Excel formats, allowing you to easily view, edit, and analyze exported Tally financial reports without expensive subscriptions.

  1. 1. Export Data from Tally: In Tally, navigate to your Trial Balance, press Alt+E to open the Export menu, and choose 'Excel (Spreadsheet)' as your output format.
  2. 2. Download WPS Office: Install WPS Office Free from the official website to get access to WPS Spreadsheet.
  3. 3. Open and Analyze: Launch WPS Spreadsheet and open the exported Trial Balance file to start filtering, formatting, and analyzing your financial data.
Seamlessly opens and edits Microsoft Excel (.xlsx, .xls, .csv) formats exported directly from Tally.Highly compatible with advanced spreadsheet formulas for financial data analysis.Lightweight architecture handles large trial balances and financial datasets smoothly.Familiar tabbed interface ensures a zero-learning-curve transition from Microsoft Excel.
microsoft office alternative - wps office

Frequently Asked Questions

Can I export a Trial Balance from Tally to Excel without using VBA?

Yes, Tally provides a native export feature. Simply open the Trial Balance report in Tally, press Alt+E (Export), select 'Excel' as the destination format, and Tally will automatically generate and open the spreadsheet.

Why is my VBA ODBC connection to Tally failing?

Connection failures usually occur if Tally is closed, if the ODBC server setting is disabled in Tally's configuration, or if the port number in your VBA connection string does not match the port Tally is broadcasting on (default is 9000).

Is it possible to schedule automatic Tally to Excel imports?

Yes, by combining an automated VBA macro (using the Workbook_Open event) with Windows Task Scheduler, you can automate the extraction process. However, Tally must remain open and running on the host machine for the ODBC connection to succeed.

Where can I find pre-written VBA templates for Tally integration?

You can often find open-source VBA modules and connection examples for Tally on developer forums like Stack Overflow, GitHub repositories, and specialized accounting software communities.