Stata to Excel: From do-file to VBA
James Pike
Additional contact information
James Pike: Adelphi Real World
UK Stata Conference 2025 from Stata Users Group
Abstract:
The introduction of Stata’s putexcel command enhanced the integration between Stata and Excel, allowing users to export formatted results directly from one to the other. Via putexcel, complex outputs and spreadsheets are possible without copy-pasting or manual formatting. For many tasks, putexcel streamlines workXows and saves time. However, putexcel has limits. Some Excel features, such as conditional formatting, autoRt of cells, text to columns, or removing excess formatting, cannot be performed. However, Excel’s own language, Visual Basic for Applications (VBA), enables automation options that go beyond Stata’s scope. Using putexcel and then VBA in Excel often means running a do-file and then opening the resulting Excel file in Excel to run VBA macros. I present a method of automation where we use Stata to write and execute VBA code via a Visual Basic Script (VBS) Rle. By generating a .vbs script from within Stata (using the file command) and running it (with the shell command), users can automate Excel tasks that require VBA, all in the comfort of the Stata environment. This approach creates new possibilities for a streamlined workXow.
Date: 2025-09-04
References: Add references at CitEc
Citations:
Downloads: (external link)
http://repec.org/lsug2025/
Related works:
This item may be available elsewhere in EconPapers: Search for items with the same title.
Export reference: BibTeX
RIS (EndNote, ProCite, RefMan)
HTML/Text
Persistent link: https://EconPapers.repec.org/RePEc:boc:lsug25:02
Access Statistics for this paper
More papers in UK Stata Conference 2025 from Stata Users Group Contact information at EDIRC.
Bibliographic data for series maintained by Christopher F Baum ().