+ Reply to Thread
Results 1 to 8 of 8

Import csv into Workbook and format cells with formula to change data

  1. #1
    Registered User
    Join Date
    04-30-2019
    Location
    US
    MS-Off Ver
    Office 365
    Posts
    6

    Import csv into Workbook and format cells with formula to change data

    I have a need to adjust a master excel file to accommodate a new process. I have a csv file that has data in A thru N with D thru K showing times in format h:mm:ss. This csv file is auto generated daily and will need to be imported into a master spreadsheet into a “data” tab keeping previously imported data in the sheet (new data would be added to the next available row below). Here is where I am running into issues. The master file is formatted differently.

    The master file has data in A thru M with F thru M showing time in secs (showing 1800 instead of 0:30:00). I cannot change the csv original file to show anything other than h:mm:ss but need the master sheet to show secs due to lookups of other sheets in the file.
    In the csv, column D and E need to be added together to import into H in the master file
    In the csv, column G and H need to be added together to import into J in the master file
    In the csv there is no date being pulled in. I need to be able to when the csv is imported to generate a date (currently doing this manually based on when the file is run).


    Currently right now I am pasting the csv into a temp sheet in the master workbook and using formulas to copy, merge, convert, etc. the data into the “data” tab. Also I am manually entering a date into column A in the master file so that the data has a reference. (referenced in bullet 4 above). I would like to be able to create a macro that will do this much easier and with less steps. I don’t know if all this can be done with 1 macro or multiple of even if macros is the way to go. Any help would be appreciated. I have attached an example of the csv file with the data. Thank you in advance.
    Attached Files Attached Files

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Import csv into Workbook and format cells with formula to change data

    We will also need to see the master file into which this data is placed.

    I will probably "pave the cow path" and do something similar to what you are doing manually, but only doing it in VB.
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

  3. #3
    Registered User
    Join Date
    04-30-2019
    Location
    US
    MS-Off Ver
    Office 365
    Posts
    6

    Re: Import csv into Workbook and format cells with formula to change data

    I have attached the master file as well for reference.
    Attached Files Attached Files

  4. #4
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Import csv into Workbook and format cells with formula to change data

    I s there a particular reason you have this file in XLS (pre-2007) format? I will convert it.

  5. #5
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Import csv into Workbook and format cells with formula to change data

    I'll need a mapping of what columns in the CSV file you want to go to which columns in the master file. The column titles don't match.

    I have a suspicion that Staffed Time, Talk Time and Wrapped are computed.

    I have a formula for the key. I will assign the date based on the file date of the CSV file (when it was last saved).

  6. #6
    Registered User
    Join Date
    04-30-2019
    Location
    US
    MS-Off Ver
    Office 365
    Posts
    6

    Re: Import csv into Workbook and format cells with formula to change data

    Thank you for looking at this. I am sorry for the confusion with my 2 files. I have compared the 2 files and listed how they map over from CSV to Master. As for the file format being 2007, I just saved it in the wrong format.

    In the CSV "A" map to Master file column "C"
    In the CSV "B" map to Master file column "F"
    In the CSV "C" map to Master file column "E"
    In the CSV "D" and "E" map to Master file column "H"
    In the CSV "F" map to Master file column "I"
    In the CSV "G" and "H" map to Master file column "J"
    In the CSV "I" map to Master file column "K"
    In the CSV "J" map to Master file column "L"
    In the CSV "K" map to Master file column "M"

  7. #7
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Import csv into Workbook and format cells with formula to change data

    Create two directories:
    - An "In Basket" to hold the CSV files to be imported. The CSV files should be the only files in this directory
    - An "Out Basket where the files will be placed after being imported so they are archived and don't get imported twice

    Enter in the full path name of these two directories in Cells B1 and B2 on the Control Panel Sheet.

    The control panel sheet also shows the mapping you provided me.

    I make use of tables because tables "know" how big they are and copy down formulas automatically. The tables do most of the work for me and I just sew the pieces together with VBA.

    The program loops through every CSV file in the in basket, processes it and moves it to the out basket.

    Each file is read into an Import Table and this table has helper columns to convert the time to number of seconds and to do the other math. The date is gotten from the date property of the CSV file.

    The program reads the map and unscrambles the columns into the master table.

    I took a liberty and replaced the key with a formula of my own. It puts in delimiters which makes it a bit easier to read. It assures that the combination of date, login time and agent ID is unique. If you don't like it, you can plug in your original formula.
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    04-30-2019
    Location
    US
    MS-Off Ver
    Office 365
    Posts
    6

    Re: Import csv into Workbook and format cells with formula to change data

    I have checked the file and everything appears to be working. Thank you for your assistance with this!

+ 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. [SOLVED] Pull-data-from-a-closed-workbook Format change VBA
    By rajeshn_in in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-04-2017, 08:55 AM
  2. [SOLVED] Copying data to new cells based on a conditional format change
    By bawlmer in forum Excel General
    Replies: 2
    Last Post: 11-12-2015, 08:00 AM
  3. [SOLVED] delete data and change date format formula
    By britt.gregoire in forum Excel Formulas & Functions
    Replies: 17
    Last Post: 04-08-2013, 03:54 PM
  4. Replies: 4
    Last Post: 01-12-2013, 02:42 PM
  5. Replies: 13
    Last Post: 11-26-2012, 12:57 PM
  6. Get data from source workbook and paste to destination in change format
    By farrukh in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-03-2012, 01:47 AM
  7. Conditional Format to change entire row based on one cells data
    By Crowbar via OfficeKB.com in forum Excel General
    Replies: 2
    Last Post: 10-25-2005, 11:05 AM

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