Results 1 to 7 of 7
  1. #1
    Bronze Lounger
    Join Date
    Feb 2008
    Posts
    1,420
    Thanks
    124
    Thanked 5 Times in 5 Posts

    Macro to open specific directory and copy data

    I would like a macro to do the following

    1) Open directory C:\Man_Accts so as to allow me to select a csv file that was downloaded (have had to save file as an excel file as site does not allow csv file to be uploaded KBRR_2013022
    2) Once the csv file has been selected (see attached sample), I need the data in columns B:E to be copied from row1 to the destination workbook in sheet TBTXT in Col B:E from row3 onwards-I have copied the data manually into the destination workbook -sheet TBTXT to show you what it should look like after being copied using a macro

    Your assistance in resolving this is most appreciated


    http://www.excelfox.com/forum/f2/mac...ific-data-859/
    Attached Files Attached Files

  2. #2
    WS Lounge VIP
    Join Date
    Mar 2002
    Location
    Newcazzle, UK
    Posts
    2,822
    Thanks
    134
    Thanked 481 Times in 458 Posts
    Hi Howard

    see attached file.

    When the file browser opens, it only shows CSV files.
    (If you select a csv file that has more than the expected 5 data columns, it will be rejected as invalid.)

    If the selected file is already open, the opened file will be closed and the (latest) selected file will be processed.

    I removed the filelinks from your sample file (deleting entry in cell [F1] )
    The imprted datafile name is saved in cell [D1], with its filedatestamp placed in cell [F1]

    Please let me know if this is what you wanted.

    zeddy
    Attached Files Attached Files

  3. The Following User Says Thank You to zeddy For This Useful Post:

    HowardC (2013-03-24)

  4. #3
    WS Lounge VIP
    Join Date
    Mar 2002
    Location
    Newcazzle, UK
    Posts
    2,822
    Thanks
    134
    Thanked 481 Times in 458 Posts
    Hi Howard

    If you save the file as attached in post#2 in your directory C:\Man_Accts , it will then use that location for its default file browser start folder.

    zeddy

  5. #4
    Bronze Lounger
    Join Date
    Feb 2008
    Posts
    1,420
    Thanks
    124
    Thanked 5 Times in 5 Posts
    Hi Zeddy

    Thanks for the help. This is exactly what I need

    Regards

    Howard

  6. #5
    Bronze Lounger
    Join Date
    Feb 2008
    Posts
    1,420
    Thanks
    124
    Thanked 5 Times in 5 Posts
    Hi Zeddy

    I need one small change. Once the file has been opened and the data copied, I would like the name of the file to be extracted on sheet "Extract" and placed in cell N13

    Your assistance in this regard is most appreciated

    Regards

    Howard

  7. #6
    WS Lounge VIP
    Join Date
    Mar 2002
    Location
    Newcazzle, UK
    Posts
    2,822
    Thanks
    134
    Thanked 481 Times in 458 Posts
    Hi Howard

    In the file I sent, the filename for the source CSV file was placed in cell [D1] on sheet [TBTXT2]

    I can do what you ask, but there isn't a sheet named [Extract].
    Do you want me to create one? Or do you have another file that you want me to do this for?

    zeddy

  8. #7
    Bronze Lounger
    Join Date
    Feb 2008
    Posts
    1,420
    Thanks
    124
    Thanked 5 Times in 5 Posts
    Hi Zeddy

    My apologies. I overlooked this. The File name is being extracted correctly

    Regards

    Howard

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •