MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Export[] to XLS

  • To: mathgroup at
  • Subject: [mg62355] Re: [mg62337] Export[] to XLS
  • From: Bob Hanlon <hanlonr at>
  • Date: Tue, 22 Nov 2005 04:41:57 -0500 (EST)
  • Reply-to: hanlonr at
  • Sender: owner-wri-mathgroup at

One way would be to import the intended sheet name into the first cell of 
each sheet and add the following macro to the code module of the workbook 
or an add-on.  Manually run the macro or put a call to it in an Auto_Open 

Bob Hanlon

        Public Sub reName_Sheets()
            ' Renames sheets from their default names (e.g., "Sheet1")
            ' to value in sheet's first cell (A1) except when that cell is
            ' blank
            Dim fenSheet ' Index used in For Each ... Next loop
            For Each fenSheet In Sheets
                If Left(fenSheet.Name, 5) = "Sheet" And _
                    Not fenSheet.Range("A1") = "" Then
                    fenSheet.Name = fenSheet.Range("A1")
                End If
            Next fenSheet ' in Sheets
        End Sub ' reName_Sheets

> From: ggroup at
To: mathgroup at
> Date: 2005/11/21 Mon AM 03:54:19 EST
> Subject: [mg62355] [mg62337] Export[] to XLS
> I occasionally need to export data sets (LxNxM) to Excel.  This
> usually works extremely well using Export["filename",data,"XLS"].  By
> default, Mathematica will create L worksheets, each with an NxM table.
> My question is, is there a way to give a meaningful name to those
> worksheets from Mathematica?  Obviously the filename is specified, and
> it is fairly trivial to add column and/or row headings to the tables
> on each worksheet.  I just haven't found the trick to naming each
> worksheet automatically.
> Thanks.

  • Prev by Date: Re: TagSetDelayed and UpValues
  • Next by Date: Re: Confusing results with N[expr]?
  • Previous by thread: Re: Export[] to XLS
  • Next by thread: TagSetDelayed and UpValues