+ Reply to Thread
Results 1 to 4 of 4

Copy specified text file and paste to correspondence excel sheets

  1. #1
    Registered User
    Join Date
    07-26-2018
    Location
    germany
    MS-Off Ver
    2010
    Posts
    13

    Copy specified text file and paste to correspondence excel sheets

    Hello All,

    I have so many text file in one folder. Now I want to check if the text file name is "a" or "b" or "c", then it will copy and paste to correspondence excel sheets ( Like text file a paste in sheet name a....). all excel sheets are empty. i want to just copy text file and paste in the correspondence excel sheet..
    Can anyone suggest a code?
    Thanks in advance

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,929

    Re: Copy specified text file and paste to correspondence excel sheets

    Edit: Sorry, forgot to state that this code requires a reference to MS scripting Runtime.


    Use the code below in a macro-enabled workbook saved in the folder with your text files. I have assumed that the sheet names are single letters - if that is not the case, then you could replace

    Please Login or Register  to view this content.
    with

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Registered User
    Join Date
    07-26-2018
    Location
    germany
    MS-Off Ver
    2010
    Posts
    13

    Re: Copy specified text file and paste to correspondence excel sheets

    Hi Bernie,

    thanks for your help.
    I applied your code in my userform..But it cannot find a text files. can you check it in attachments?..I want to select a folder in userform("In Search"). According to this folder, it will check for text file and copied top the main excel sheets.
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,929

    Re: Copy specified text file and paste to correspondence excel sheets

    I had run my test code from the same folder - so the default worked for me. When you change folders, the code needs to bechanged to allow that:

    So, change this line

    Please Login or Register  to view this content.
    to this:

    Please Login or Register  to view this content.

+ 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] VB Code to copy and paste text file into excel.
    By rizmomin in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 09-06-2017, 03:46 PM
  2. Copy Visible Range in Excel and Paste into Text File
    By jpv5 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 09-14-2016, 09:15 AM
  3. Replies: 0
    Last Post: 04-29-2015, 10:59 PM
  4. [SOLVED] VB Code to copy and paste from all text file and paste into single file
    By rizmomin in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 04-29-2015, 06:00 PM
  5. Replies: 2
    Last Post: 10-29-2014, 10:23 AM
  6. [SOLVED] Unable to copy and paste a text file into excel
    By Jack40 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-23-2012, 10:53 PM
  7. Replies: 1
    Last Post: 10-17-2005, 04:05 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