+ Reply to Thread
Results 1 to 4 of 4

Export Excel SpreadSheet with VBA.

Hybrid View

  1. #1
    Registered User
    Join Date
    09-19-2012
    Location
    Singapore
    MS-Off Ver
    Excel 2010
    Posts
    6

    Export Excel SpreadSheet with VBA.

    I have a main workbook which i use to generate Purchase Orders in spreadsheets. There are 4 types of purchase orders that would be exported into their own respective workbook. I want to have a button that would export the PO into another workbook.
    I am fairly new to VBA so please explain as simplistic as possible (: Thanks in advance!

  2. #2
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Export Excel SpreadSheet with VBA.

    Sub SaveSheetToFile()
        myPath = "D:\DATA\test\"
        arr = Array("Sheet1", "Sheet2", "Sheet3","Sheet4") '  put real sheets names in array arr
        For j = 0 To 3
          Filenam = arr(j)
          Sheets(Filenam).Copy ' create new workbook with single sheet for saving
          ActiveWorkbook.SaveAs Filename:=myPath & Filenam & ".xlsx", CreateBackup:=False
          ActiveWorkbook.Close
        Next
    End Sub
    Last edited by patel45; 10-01-2012 at 02:45 AM.
    If solved remember to mark Thread as solved

  3. #3
    Registered User
    Join Date
    09-19-2012
    Location
    Singapore
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Export Excel SpreadSheet with VBA.

    Hi,

    Can you explain to me about the code please,and what is j, is it a variable?if so, dont you need to define it?

  4. #4
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Export Excel SpreadSheet with VBA.

    j is a variable, with vba is possible, but not recommended, to avoid declaration of variables.
    see comments on above code

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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