Results 1 to 4 of 4

saveas worksheets without renaming workbook

Threaded View

  1. #1
    Registered User
    Join Date
    10-01-2011
    Location
    Pittsford, NY, USA
    MS-Off Ver
    Excel 2007
    Posts
    6

    saveas worksheets without renaming workbook

    Hello, Everyone,

    I’m trying to export two of the five worksheets in my Excel workbook as csv files. I have the following code, which works a charm:

    Dim wsXXX As Worksheet, wsYYY As Worksheet
    Set wsXXX = Worksheets("XXX")
    Set wsYYY = Worksheets("YYY")
    strFilenameXXX = "XXX-ABC" & "DEF-" & Year(Date) & Format(Month(Date), "00") & Format(Day(Date), "00")
    strFilenameYYY = "XXX-ABC" & "DEF-" & Year(Date) & Format(Month(Date), "00") & Format(Day(Date), "00")
    wsXXX.SaveAs strFilenameXXX & ".csv", xlCSV
    wsYYY.SaveAs strFilenameYYY & ".csv", xlCSV
    But once these lines of code have run, a couple of things go very wrong
    * First, within my workbook, the two worksheets have been renamed as strFilenameYYY
    * Second, my entire workbook has been renamed strFilenameYYY

    How can I export the two worksheets without changing their names within the workbook and the name of the workbook itself?

    Thanks!
    Vincent
    Attached Files Attached Files
    Last edited by val64; 10-02-2011 at 03:40 PM. Reason: remove ambiguity

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1