Can Excel VBA Search Microsoft Teams for a Person's Email?
Question details
The user wants to enter a name in an Excel worksheet and automatically search Microsoft Teams to retrieve the corresponding email address.

- Product
- Microsoft Excel, Microsoft Teams
- Device & OS
- not provided
- Scenario
- Trying to automate the retrieval of a person's email address from Microsoft Teams based on a name entered into an Excel worksheet.
- Observed behavior
- Excel's native functions like XLOOKUP and standard VBA cannot directly communicate with or search Microsoft Teams.
Searching Microsoft Teams directly from Excel requires advanced cloud integrations like Microsoft Graph API or Power Automate, as standard VBA or built-in formulas cannot query Teams natively.
Use Power Automate to Connect Excel and Office 365 Users
Since standard VBA cannot directly query Teams, Power Automate provides a seamless, low-code way to connect Excel data with Microsoft 365 user directories to retrieve emails.
Power Automate runs in the cloud, meaning this solution will work across Windows, Mac, and mobile devices, bypassing the limitations of local VBA macros.
Ensure your Excel file is saved in OneDrive or SharePoint. Format the list of names in your worksheet as a formal Excel Table.
Log into Power Automate online and create a new flow. You can use an 'Instant cloud flow' triggered by a selected row in your Excel table.
Add a new step and choose the 'Search for users (V2)' action under the Office 365 Users connector. Map the search term to the Name column from your Excel table.
Add an 'Update a row' action for Excel Online. Configure it to write the retrieved 'Mail' dynamic content back into the designated email column in your spreadsheet.

Query Microsoft Graph API using Excel VBA
For developers who strictly require a VBA-based solution, you can write advanced code to authenticate and query the Microsoft Graph API to find user details.
Looking for a powerful, free spreadsheet editor?
While querying Microsoft Teams requires complex API integrations, for your everyday data analysis and macro needs, WPS Office offers a lightweight, highly compatible, and free alternative to Microsoft Office. Enjoy seamless formatting and comprehensive formula support without the subscription fees.
- 1. Download WPS Office: Visit the official WPS website and download the free installation package for your operating system.
- 2. Install the Application: Run the installer and follow the on-screen prompts to set up WPS Office on your device.
- 3. Open Your Spreadsheets: Launch WPS Spreadsheets and open your existing .xlsx files to start working immediately with full compatibility.

Frequently Asked Questions
Can I use XLOOKUP to search data across different applications?
No, XLOOKUP is strictly designed to search for data within Excel workbooks. It cannot communicate with external applications like Microsoft Teams, Outlook, or external databases directly without a backend data connection.
Is there any built-in Excel function to get a user's email from Teams?
There is no native Excel formula that fetches user emails from Teams. However, if your organization uses Microsoft 365, you may be able to use the 'Organization' linked data types to pull employee details directly into cells.
Why doesn't standard VBA work with Microsoft Teams?
VBA is a legacy automation language designed to interact with desktop Office applications using local COM objects. Microsoft Teams is a modern cloud-based application without a local COM interface, meaning integrations require REST APIs like Microsoft Graph.
What is the best way to make this search work on mobile devices?
Since VBA macros do not run on Excel for mobile, the best approach is to build a Power App or use a cloud-based Power Automate flow. This ensures the data lookup runs on a remote server and works identically across Windows, Android, and iOS devices.




