Here's what I use to (semi-)intelligently export all worksheets in a workbook to CSV files. In VBA:

Sub BulkCSVExport() ' Export all worksheets to .CSV files. ' Surround text (not numbers!) with double quotes. ' Handle text that contains double quotes, as in: 18" X 11" X 11 +" Dim DestFile As String Dim FileNum As Integer Dim ColumnCount As Integer Dim RowCount As Integer Dim st As Integer Dim strTemp As String Dim wbk As Workbook Dim sht As Worksheet Dim intSheetCount As Integer Application.ScreenUpdating = False Set wbk = Application.ActiveWorkbook For intSheetCount = 1 To wbk.Sheets.Count Set sht = wbk.Sheets.Item(intSheetCount) sht.Activate DestFile = wbk.Name & "." & sht.Name & ".CSV" FileNum = FreeFile() On Error Resume Next Open DestFile For Output As #FileNum If Err <> 0 Then MsgBox "Cannot open filename " & DestFile End End If On Error GoTo 0 ActiveSheet.UsedRange.Select For RowCount = 1 To Selection.Rows.Count For ColumnCount = 1 To Selection.Columns.Count If IsNumeric(Selection.Cells(RowCount, ColumnCount +)) Then Print #FileNum, Selection.Cells(RowCount, _ ColumnCount).Value; Else ' strTemp = Selection.Cells(RowCount, ColumnCoun +t).Text ' Fix double quotes, lest they confuse the .CS +V format If InStr(strTemp, CStr(Chr$(34))) <> 0 Then st% = 1 While st% <= Len(strTemp) And InStr(st%, st +rTemp, CStr(Chr$(34))) > 0 st% = InStr(st%, strTemp, CStr(Chr$(34)) +) strTemp = Left$(strTemp, st%) & CStr(Chr +$(34)) & Mid$(strTemp, st% + 1) st% = st% + 2 Wend End If ' Print #FileNum, CStr(Chr$(34)) & strTemp & CSt +r(Chr$(34)); End If If ColumnCount = Selection.Columns.Count Then Print #FileNum, Else Print #FileNum, ","; End If Next ColumnCount Next RowCount Close #FileNum Next Application.ScreenUpdating = True End Sub

Modifications, calling from Perl, and diffing the output are all left as exercises for the reader.

planetscape

In reply to Re: Comparing two Excel spread sheets by planetscape
in thread Comparing two Excel spread sheets by Win

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.