Results 1 to 5 of 5

Help modifying a batch processing Macro

Threaded View

a_stansbury Help modifying a batch... 04-15-2014, 01:24 PM
Richard Buttrey Re: Help modifying a batch... 04-15-2014, 01:29 PM
a_stansbury Re: Help modifying a batch... 04-15-2014, 01:33 PM
Richard Buttrey Re: Help modifying a batch... 04-15-2014, 02:15 PM
a_stansbury Re: Help modifying a batch... 04-15-2014, 02:44 PM
  1. #1
    Registered User
    Join Date
    04-15-2014
    Location
    Edinburgh, Scotland
    MS-Off Ver
    Excel 2010
    Posts
    4

    Question Help modifying a batch processing Macro

    Hello, I am new to using the macro function in excel, and would greatly appreciate help creating a function to batch process my data. I have a directory of text files which I would like to import into excel in order, and then to automatically produce the average and mid point for each column (for each file individually). I have attached the script for running two files individually (another tricky bit is to note that the files all have the same columns, but are variable in rows). I don't know where to begin to get it to batch process the thousands of files I have.

    I greatly appreciate your help!

    Sub Macro_example()
    '
    ' Macro_example Macro
    ' This shows an example of the steps that I need a macro to complete.  2 files are processed here, and I have a directory of thousands of text files labelled numerically (label is the same as input to column A) I would like to automatically import.
    '
    ' Keyboard Shortcut: Ctrl+Shift+B
    '
        Range("A2").Select
        ActiveCell.FormulaR1C1 = "1"
        Range("B2").Select
        With ActiveSheet.QueryTables.Add(Connection:= _
            "TEXT;C:\Users\Public.Stansbury\Desktop\Formant vocal learning\Praat outputs\1." _
            , Destination:=Range("$B$2"))
            .Name = "1._1"
            .FieldNames = True
            .RowNumbers = False
            .FillAdjacentFormulas = False
            .PreserveFormatting = True
            .RefreshOnFileOpen = False
            .RefreshStyle = xlInsertDeleteCells
            .SavePassword = False
            .SaveData = True
            .AdjustColumnWidth = True
            .RefreshPeriod = 0
            .TextFilePromptOnRefresh = False
            .TextFilePlatform = 850
            .TextFileStartRow = 2
            .TextFileParseType = xlFixedWidth
            .TextFileTextQualifier = xlTextQualifierDoubleQuote
            .TextFileConsecutiveDelimiter = False
            .TextFileTabDelimiter = True
            .TextFileSemicolonDelimiter = False
            .TextFileCommaDelimiter = False
            .TextFileSpaceDelimiter = False
            .TextFileColumnDataTypes = Array(1, 1, 1, 1, 1)
            .TextFileFixedColumnWidths = Array(8, 16, 13, 14)
            .TextFileTrailingMinusNumbers = True
            .Refresh BackgroundQuery:=False
        End With
        Range("G2").Select
        ActiveCell.FormulaR1C1 = "=AVERAGE(RC[-5]:R[26]C[-5])"
        Range("G2").Select
        Selection.AutoFill Destination:=Range("G2:K2"), Type:=xlFillDefault
        Range("G2:K2").Select
        Range("B15:F15").Select
        Selection.Copy
        Range("L2").Select
        ActiveSheet.Paste
        ActiveWindow.ScrollRow = 2
        ActiveWindow.ScrollRow = 3
        ActiveWindow.ScrollRow = 4
        ActiveWindow.ScrollRow = 5
        ActiveWindow.ScrollRow = 6
        ActiveWindow.ScrollRow = 7
        ActiveWindow.ScrollRow = 8
        ActiveWindow.ScrollRow = 9
        ActiveWindow.ScrollRow = 10
        ActiveWindow.ScrollRow = 11
        ActiveWindow.ScrollRow = 12
        ActiveWindow.ScrollRow = 13
        ActiveWindow.ScrollRow = 14
        ActiveWindow.ScrollRow = 15
        ActiveWindow.ScrollRow = 16
        Range("A29").Select
        Application.CutCopyMode = False
        ActiveCell.FormulaR1C1 = "2"
        Range("B29").Select
        With ActiveSheet.QueryTables.Add(Connection:= _
            "TEXT;C:\Users\Public.Stansbury\Desktop\Formant vocal learning\Praat outputs\2." _
            , Destination:=Range("$B$29"))
            .Name = "2._1"
            .FieldNames = True
            .RowNumbers = False
            .FillAdjacentFormulas = False
            .PreserveFormatting = True
            .RefreshOnFileOpen = False
            .RefreshStyle = xlInsertDeleteCells
            .SavePassword = False
            .SaveData = True
            .AdjustColumnWidth = True
            .RefreshPeriod = 0
            .TextFilePromptOnRefresh = False
            .TextFilePlatform = 850
            .TextFileStartRow = 2
            .TextFileParseType = xlFixedWidth
            .TextFileTextQualifier = xlTextQualifierDoubleQuote
            .TextFileConsecutiveDelimiter = False
            .TextFileTabDelimiter = True
            .TextFileSemicolonDelimiter = False
            .TextFileCommaDelimiter = False
            .TextFileSpaceDelimiter = False
            .TextFileColumnDataTypes = Array(1, 1, 1, 1, 1)
            .TextFileFixedColumnWidths = Array(8, 16, 12, 14)
            .TextFileTrailingMinusNumbers = True
            .Refresh BackgroundQuery:=False
        End With
        Range("G29").Select
        ActiveCell.FormulaR1C1 = "=AVERAGE(RC[-5]:R[11]C[-5])"
        Range("G29").Select
        Selection.AutoFill Destination:=Range("G29:K29"), Type:=xlFillDefault
        Range("G29:K29").Select
        Range("B34:F34").Select
        Selection.Copy
        Range("L29").Select
        ActiveSheet.Paste
        ActiveWindow.ScrollRow = 24
        ActiveWindow.ScrollRow = 23
        ActiveWindow.ScrollRow = 21
        ActiveWindow.ScrollRow = 19
        ActiveWindow.ScrollRow = 17
        ActiveWindow.ScrollRow = 16
        ActiveWindow.ScrollRow = 15
        ActiveWindow.ScrollRow = 14
        ActiveWindow.ScrollRow = 13
        ActiveWindow.ScrollRow = 12
        ActiveWindow.ScrollRow = 11
        ActiveWindow.ScrollRow = 9
        ActiveWindow.ScrollRow = 8
        ActiveWindow.ScrollRow = 6
        ActiveWindow.ScrollRow = 4
        ActiveWindow.ScrollRow = 1
    End Sub
    Last edited by a_stansbury; 04-15-2014 at 01:33 PM. Reason: Starting/ending code

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Sheet-related processing causes Excel VBA Userform to stop processing Tab/Enter
    By Joaquin M Lopez Muno in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 03-22-2014, 03:02 PM
  2. Help finding a "batch processing" technique for a userform???
    By WillRn in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-27-2005, 10:05 AM
  3. Open Batch File For Processing
    By Chuckles123 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-15-2005, 09:05 AM
  4. excel batch processing
    By anwarbham in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-18-2005, 12:09 PM
  5. how to batch processing excel worksheet modifications?
    By neptune in forum Excel General
    Replies: 4
    Last Post: 01-13-2005, 05:06 PM

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