Office for Mac Issues

Create an ODBC SQL Server Connection with VBA in Excel for Mac

Natalie TaylorNatalie Taylor Nov 27, 2026 870 views

Question details

Determine how to create an ODBC connection to SQL Server using VBA in Excel 2016 for Mac.

Create an ODBC SQL Server Connection with VBA in Excel for Mac
Product
Microsoft Excel 2016 for Mac
Device & OS
Mac, macOS version not provided
Scenario
A user wants to automate a SQL Server ODBC connection in Excel on a Mac, potentially using code written for Windows.
Observed behavior
Excel may support an ODBC connection through its interface, but Windows VBA connection-creation code may not work unchanged, and a recorded macro may capture only the data retrieval step.
Before you start

Confirm your Excel version and obtain the SQL Server address, database name, and authentication details from your administrator. Check that a compatible Mac ODBC driver is available and that the server permits connections from your Mac.

Solution 1Recommended

Set up and test the ODBC connection in Excel for Mac

Use Excel's interface to verify the driver, data source, and server access before attempting VBA automation.

A successful connection through the interface confirms that the data source works, but it does not establish that VBA can create the same connection in your Excel version.

1
Install the ODBC driver

Install a SQL Server ODBC driver for macOS that is compatible with your Excel version and its architecture. Follow the driver provider's installation instructions.

2
Configure a data source

Open an ODBC administrator tool compatible with the driver and create a data source name (DSN) with the SQL Server address and database details. Use the driver's test option if one is available.

3
Connect from Excel

In Excel, open the Data tab and look for the external data or database query option. Select the configured ODBC data source, enter your authentication details when prompted, and retrieve a small set of data. Menu names can vary by Excel version.

4
Check access if it fails

If the connection fails, check the server address and credentials, then ask your server administrator to confirm network and SQL Server access from your Mac.

Free Microsoft Office alternative

Work with Excel spreadsheets in WPS Office

WPS Office is a free, lightweight alternative with a familiar spreadsheet interface and Microsoft Office format compatibility for an easier move between office suites. It does not fix Excel for Mac's VBA or ODBC limitations.

Open and edit Microsoft Excel XLSX and XLS filesUse a familiar spreadsheet interface for everyday workbook tasksWork with a lightweight, free office suiteMove standard Office documents between suites with format compatibility
microsoft office alternative - wps office

Frequently Asked Questions

Why does the recorded macro only show the data retrieval step?

Excel for Mac may not record every step used to create an ODBC connection. Open Tools > Macro > Visual Basic Editor to inspect what was recorded; the omission alone does not confirm whether connection creation is supported by VBA.

Will my Windows VBA connection code work on Excel for Mac?

Not necessarily. Windows code may depend on drivers, components, or VBA features that differ on macOS. Test the ODBC data source in Excel first, then check the code against the capabilities of your Mac Excel version.

What should I check if Excel cannot reach SQL Server?

Verify the server address, database, credentials, and DSN in your ODBC administrator tool. Ask your server administrator to confirm that SQL Server and the network allow connections from your Mac.

Can I refresh an existing connection without creating it in VBA?

Yes, if the connection works in Excel and your version supports the recorded refresh command. Create it through the Data tab, record a macro while using Data > Refresh All, and test the resulting code.