+ Reply to Thread
Results 1 to 2 of 2

Macro to loop through data validation saving extract results as text files

  1. #1
    Registered User
    Join Date
    04-10-2013
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    1

    Macro to loop through data validation saving extract results as text files

    Hello,

    This is my first VBA attempt so it may not be pretty, but I appreciate any help.

    I have a file that contains a toggle which allows the user to select various views. For each view, a tab in the spreedsheet needs to be copied to a new workbook and saved as a text file. I have managed to get the copy / paste / save portion of the code pieced together as per below:

    PHP Code: 
    Sub TextFileCreation()
    '
    TextFileCreation Macro
    '
    Keyboard ShortcutCtrl+Shift+J
    '
     
     ActiveWorkbook.Sheets("EXPORT FILE_DO NOT CHANGE").Activate
     ActiveSheet.Copy
        With ActiveSheet.UsedRange
            .Copy
            .PasteSpecial xlValues
            .PasteSpecial xlFormats
        End With
        Application.CutCopyMode = False

    ActiveWorkbook.SaveAs Filename:=Range("B5").Value, FileFormat:=xlTextWindows
    ActiveWorkbook.Close

    ActiveWorkbook.Sheets("SAP LoadFile").Activate
     

    End Sub 

    I would like the above action to loop through the data validation options (Data validation list is located in cell B5 of the 'SAP LoadFile' tab - list reference is located on 'Drop Down' tab in cells A1:A71 - range is named 'Store'). until all possible views provided by the drop down list are saved as text files.

    One additional teak if possible is that in the above code I have not figured out how indicate which folder to save to - if fix for this is available that would be great as well.

    Thank you for your help in advance.
    Last edited by Jugo; 04-11-2013 at 06:43 PM.

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,474

    Re: Macro to loop through data validation saving extract results as text files

    Looking at you code, it appears you are copying a range but have not indicated where to past it.


    Attach a sample workbook. Make sure there is just enough data to make it clear what is needed. Include BEFORE/AFTER sheets if needed to show the process you're trying to complete or automate. Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic

+ 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