+ Reply to Thread
Results 1 to 9 of 9

Modify code to import to all worksheets

  1. #1
    Forum Contributor
    Join Date
    07-21-2010
    Location
    Alta, Norway
    MS-Off Ver
    Excel 2003
    Posts
    119

    Modify code to import to all worksheets

    Hi,

    I am using the following code to import all files in a directory.
    Could someone please assist me in modifying the code, so that the imported files is pasted in all worksheets, not just the first (sheet1)?

    Please Login or Register  to view this content.
    Duplicate: http://www.mrexcel.com/forum/showthread.php?t=484275

    Gnoke
    Last edited by gnoke; 08-10-2010 at 09:48 AM.

  2. #2
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: Modify code to all worksheets

    Untested

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    07-21-2010
    Location
    Alta, Norway
    MS-Off Ver
    Excel 2003
    Posts
    119

    Re: Modify code to all worksheets

    Thanks for replay!

    I get the following error: "Invalid Next control variable reference" on line number 10 from the buttom "Next i"
    Any ideas?
    Last edited by gnoke; 07-28-2010 at 04:46 AM. Reason: spelling mistake

  4. #4
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: Modify code to all worksheets

    I forgot to close my new loop

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    07-21-2010
    Location
    Alta, Norway
    MS-Off Ver
    Excel 2003
    Posts
    119

    Re: Modify code to all worksheets

    Thanks again for your replay!

    Now the macro runs, but I see no differens in the output compared to the prior macro.
    The text files are not imported to any sheets except the first...

    Ideas someone?
    Last edited by gnoke; 07-29-2010 at 03:24 AM.

  6. #6
    Forum Contributor
    Join Date
    07-21-2010
    Location
    Alta, Norway
    MS-Off Ver
    Excel 2003
    Posts
    119

    Re: Modify code to all worksheets

    Anyone else that have any ideas?
    Would reallt appreciate any further assistance

  7. #7
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: Modify code to import to all worksheets

    Maybe I misunderstood the brief. Try this version

    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    07-21-2010
    Location
    Alta, Norway
    MS-Off Ver
    Excel 2003
    Posts
    119

    Re: Modify code to import to all worksheets

    Hi and thanks again Bob!

    We are defininitly getting somewhere now, but still have two issues.
    1. The macro imports to all sheets nicely, but only one text file, not all text files in the specified folder.
    2. The single text file is also imported to a new workbook...

    Gnoke

  9. #9
    Forum Contributor
    Join Date
    07-21-2010
    Location
    Alta, Norway
    MS-Off Ver
    Excel 2003
    Posts
    119

    Re: Modify code to import to all worksheets

    Solution for me:

    1. I use this code to import all text files into a single sheet:

    Please Login or Register  to view this content.
    2. Then i created new macros to delete rows with specific values in specific cells (or else delete rows with empty cells).
    3. Then I recorded simple macros to e.g. arrange the rows ascending based text in column A.
    4. In the end I recorded a macro while running all the simple macros.

    This is probably not the most efficient for my job, but it does what I need
    Thanks for all help!
    Gnoke

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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