+ Reply to Thread
Results 1 to 3 of 3

Formating several files based on one

Hybrid View

juansalix Formating several files based... 12-10-2018, 07:15 AM
davsth Re: Formating several files... 12-10-2018, 09:14 AM
davsth Re: Formating several files... 12-10-2018, 09:15 AM
  1. #1
    Registered User
    Join Date
    12-06-2018
    Location
    Norway
    MS-Off Ver
    1811
    Posts
    31

    Formating several files based on one

    Hello,

    I wonder if somebody could help me with this one. I have around 400 files with the exact same format and need to add an extra column to every single one of them. The column also needs to be time formated to hh:mm:ss.000.

    I've attached an example of the first file. This one could be use as a "model file". The new column to be added starts in cell J17, and contains the following formula: =A17/86400 which should be dragged down depending on the number of cells of column A. As mentionned previously, the new column J also needs custom formating to hh:mm:ss.000

    Note that on all of the files the length of column A varies, although column J always starts on cell J17 with the same exact formula.

    Any help is appreciated! I've been trying to do this task manually but my guess is that there should be a better way to do this and hopefuly I will also learn something new out of it.

    Very best
    Juan
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    10-10-2016
    Location
    Sheffield
    MS-Off Ver
    365 and rarely 2016
    Posts
    3,212

    Re: Formating several files based on one

    duplicate post
    Last edited by davsth; 12-10-2018 at 09:16 AM. Reason: posted twice

  3. #3
    Forum Expert
    Join Date
    10-10-2016
    Location
    Sheffield
    MS-Off Ver
    365 and rarely 2016
    Posts
    3,212

    Re: Formating several files based on one

    Are the files all in the same folder? And are either other files in the folder?

    There are many bits of vba code on here that loop through all the files in a folder you put this code into a master workbook and then run it for all the files in a folder the you define. It is looking for all xls files but you could change it to fit accordingly, but hopefully a start

    Sub OpenFiles()
    Dim MyFolder As String
    Dim MyFile As String
    MyFolder = "C:\example"
    MyFile = Dir(MyFolder & "\*.xls")
    Do While MyFile <> ""
        Workbooks.Open Filename:=MyFolder & "\" & MyFile
    LastRow = ActiveSheet.Cells(ActiveSheet.Rows.Count, "A").End(xlUp).Row
    Range("J17:j"& lastrow).FormulaR1C1 = "=RC[-9]/86400"
    Range("J17:j"& lastrow)..NumberFormat = " hh:mm:ss.000"
     ActiveWorkbook.Close SaveChanges:=True
    Loop
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 18
    Last Post: 11-27-2018, 05:25 AM
  2. Excel vba to tel adobe combine two pdf files based on a spcified list of files
    By Abbadon486 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-30-2014, 12:04 PM
  3. Help with Condition based formating
    By Kartoffelmos in forum Excel General
    Replies: 2
    Last Post: 10-21-2014, 07:17 AM
  4. split text files stored in some location to multiple files based on a condition
    By GIRISH_KH in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-01-2013, 11:32 AM
  5. Condition formating a cell in a worksheet based off formating of another cell
    By bdberger1985 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-07-2013, 05:52 PM
  6. Merging two files together based on col common to both files
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-05-2011, 01:06 PM
  7. import multiple txt files in worksheet and formating
    By -haf- in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-09-2006, 01:15 AM

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