+ Reply to Thread
Results 1 to 20 of 20

Macro not returning results

  1. #1
    Valued Forum Contributor
    Join Date
    01-10-2011
    Location
    swindon, england
    MS-Off Ver
    Excel 2010
    Posts
    317

    Macro not returning results

    Hi

    I created the code below which should loop through a folder find all the CSV files and copy the values in cell range E2:E10000 and paste the values in the second column in the workbook in the template workbook and continue going along the columns.

    The code runs without error but it does not return any results and i know there are CSV files in the location i am looping through.

    Please Login or Register  to view this content.

    Does anyone know what i have done wrong in the code?

    Thanks

    Jeskit
    Last edited by jeskit; 02-02-2011 at 07:30 AM.

  2. #2
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Macro not returning results

    Hi,

    I wrote some code to do almost exactly what you are asking for someone else yesterday.

    http://www.excelforum.com/excel-prog...-workbook.html

    Shouldn't take much to adapt it.

    Dom
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

  3. #3
    Valued Forum Contributor
    Join Date
    01-10-2011
    Location
    swindon, england
    MS-Off Ver
    Excel 2010
    Posts
    317

    Re: Macro not returning results

    Hi

    Cool thanks!

    I tried your code and i adapted to mine but it still does not return any results

  4. #4
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Macro not returning results

    Have you tried stepping through the code and seeing what steps it is performing correctly or not?

    Dom

  5. #5
    Valued Forum Contributor
    Join Date
    01-10-2011
    Location
    swindon, england
    MS-Off Ver
    Excel 2010
    Posts
    317

    Re: Macro not returning results

    I just ahve and it seems to be skipping the loop bit for some reason. I have checked and there is CSV files in the folder i am teling it to look at.

  6. #6
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Macro not returning results

    Just noticed that this:

    Please Login or Register  to view this content.

    Should be:

    Please Login or Register  to view this content.

    Dom

  7. #7
    Valued Forum Contributor
    Join Date
    01-10-2011
    Location
    swindon, england
    MS-Off Ver
    Excel 2010
    Posts
    317

    Re: Macro not returning results

    Hi

    Ok tried that and it still not returning any results

  8. #8
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Macro not returning results

    Other thing to check is that your file path is correct.

    If you're using mine can you post the revised code so I can take a look at it.

    Dom

  9. #9
    Valued Forum Contributor
    Join Date
    01-10-2011
    Location
    swindon, england
    MS-Off Ver
    Excel 2010
    Posts
    317

    Re: Macro not returning results

    No Problem

    Here is the code i am using which i altered

    Please Login or Register  to view this content.
    Last edited by jeskit; 02-02-2011 at 06:57 AM.

  10. #10
    Valued Forum Contributor
    Join Date
    01-10-2011
    Location
    swindon, england
    MS-Off Ver
    Excel 2010
    Posts
    317

    Re: Macro not returning results

    Just tried it and instead of running it gave an error of "Run-time error '424': Object required" on this line
    Please Login or Register  to view this content.

  11. #11
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Macro not returning results

    Please Login or Register  to view this content.
    Should just be:

    Please Login or Register  to view this content.

    If you set Option Explicit at the top of your module it will warn you if there are typos that it thinks might be formula.

    Dom

  12. #12
    Valued Forum Contributor
    Join Date
    01-10-2011
    Location
    swindon, england
    MS-Off Ver
    Excel 2010
    Posts
    317

    Re: Macro not returning results

    Ok right it is looping through the files but its not pasting the results into the tempate workbook

  13. #13
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Macro not returning results

    Please Login or Register  to view this content.
    Last edited by snb; 02-02-2011 at 07:23 AM.



  14. #14
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Macro not returning results

    And if you step through is it performing the copy/paste?

    Dom

  15. #15
    Valued Forum Contributor
    Join Date
    01-10-2011
    Location
    swindon, england
    MS-Off Ver
    Excel 2010
    Posts
    317

    Re: Macro not returning results

    No It doesnot seem to be copying or pasting

  16. #16
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Macro not returning results

    You were copying from the wrong workbook I think:

    Please Login or Register  to view this content.

    Dom

  17. #17
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Macro not returning results

    Did you test my latest, adapted code ? (that I adapted because I forgot 1 dot).

  18. #18
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Macro not returning results

    Quote Originally Posted by snb View Post
    Avoid using VBA-code you do not understand.
    Probably followed your advice.

    Dom

  19. #19
    Valued Forum Contributor
    Join Date
    01-10-2011
    Location
    swindon, england
    MS-Off Ver
    Excel 2010
    Posts
    317

    Re: Macro not returning results

    Thank you its works now YAY!!

  20. #20
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Macro not returning results

    @Dom

    In that case the OP shouldn't use the other code in the first place.

+ 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