IDEAS home Printed from https://ideas.repec.org/p/boc/lsug25/02.html
   My bibliography  Save this paper

Stata to Excel: From do-file to VBA

Author

Listed:
  • James Pike

    (Adelphi Real World)

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.

Suggested Citation

  • James Pike, 2025. "Stata to Excel: From do-file to VBA," UK Stata Conference 2025 02, Stata Users Group.
  • Handle: RePEc:boc:lsug25:02
    as

    Download full text from publisher

    File URL: http://repec.org/lsug2025/UK25_Pike.pptx
    Download Restriction: no
    ---><---

    More about this item

    Statistics

    Access and download statistics

    Corrections

    All material on this site has been provided by the respective publishers and authors. You can help correct errors and omissions. When requesting a correction, please mention this item's handle: RePEc:boc:lsug25:02. See general information about how to correct material in RePEc.

    If you have authored this item and are not yet registered with RePEc, we encourage you to do it here. This allows to link your profile to this item. It also allows you to accept potential citations to this item that we are uncertain about.

    We have no bibliographic references for this item. You can help adding them by using this form .

    If you know of missing items citing this one, you can help us creating those links by adding the relevant references in the same way as above, for each refering item. If you are a registered author of this item, you may also want to check the "citations" tab in your RePEc Author Service profile, as there may be some citations waiting for confirmation.

    For technical questions regarding this item, or to correct its authors, title, abstract, bibliographic or download information, contact: Christopher F Baum (email available below). General contact details of provider: https://edirc.repec.org/data/stataea.html .

    Please note that corrections may take a couple of weeks to filter through the various RePEc services.

    IDEAS is a RePEc service. RePEc uses bibliographic data supplied by the respective publishers.