+ Reply to Thread
Results 1 to 11 of 11

Macro troubleshoot

  1. #1
    Forum Contributor
    Join Date
    04-03-2014
    Location
    Berlin
    MS-Off Ver
    Excel 2010
    Posts
    160

    Macro troubleshoot

    Hi guys,

    I have the following macro, which extracts data from an input file and rearranges it into a master file.
    The problem is that it runs the code 3 x times, so the final data in the master file is triple.

    Could u please help me out removing this bug!?

    Thanks a lot!

    Macro:


    Please Login or Register  to view this content.
    Last edited by alansidman; 04-24-2014 at 10:57 AM. Reason: code tags

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2509 Win 11
    Posts
    24,993

    Re: Macro troubleshoot

    Code Tags Added
    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between
    Please Login or Register  to view this content.
    tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found at http://www.excelforum.com/forum-rule...rum-rules.html



    (Because you are new to the forum, I have added them for you today. Please take a few minutes to read all Forum Rules and comply in the future.)
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Forum Contributor
    Join Date
    04-03-2014
    Location
    Berlin
    MS-Off Ver
    Excel 2010
    Posts
    160

    Re: Macro troubleshoot

    Hi Alan and thanks! Will do so from now on

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646
    Get rid of the Do Until...Loop.

    You know the name of the workbook you want to import from, it's hard-coded, so you don't need to loop through all the workbooks in a folder.
    If posting code please use code tags, see here.

  5. #5
    Forum Contributor
    Join Date
    04-03-2014
    Location
    Berlin
    MS-Off Ver
    Excel 2010
    Posts
    160

    Re: Macro troubleshoot

    Thanks Norie

    I did so and sadly it's worse than before. I mean, it runs the code once, but it does not import that data anymore ...

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: Macro troubleshoot

    That's worse than the code running 3 times?

    You need to get rid of the loop and any other code that goes with it, for example the If statement that is checking fname.
    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    04-03-2014
    Location
    Berlin
    MS-Off Ver
    Excel 2010
    Posts
    160

    Re: Macro troubleshoot

    Thanks Norie!

    It worked How would the code look like if one would implement the 'Do until - Loop' commands and if let's say, I have several files to be imported lying in the same folder "Macro Test" as the master?

    Regards

  8. #8
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: Macro troubleshoot

    It would look like the original code, but you wouldn't hard-code the workbook name you are importing from.

  9. #9
    Forum Contributor
    Join Date
    04-03-2014
    Location
    Berlin
    MS-Off Ver
    Excel 2010
    Posts
    160

    Re: Macro troubleshoot

    Exactly!

    However, I'm getting a 1004 error on this particular line:
    Please Login or Register  to view this content.
    That's why I opted for the hard-code...

  10. #10
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: Macro troubleshoot

    What code are you using now?

  11. #11
    Forum Contributor
    Join Date
    04-03-2014
    Location
    Berlin
    MS-Off Ver
    Excel 2010
    Posts
    160

    Re: Macro troubleshoot

    It works now as I need it to work, thanks a lot for your help!

+ 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. Troubleshoot macro to consolidate ranges
    By Ppsych in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-15-2012, 03:01 PM
  2. Excel 2007 : pie chart troubleshoot
    By chop924 in forum Excel General
    Replies: 1
    Last Post: 04-16-2012, 11:48 AM
  3. troubleshoot Nested IF
    By onin111 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-06-2008, 01:23 AM
  4. troubleshoot absolute value
    By Sus in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-27-2005, 01:05 PM
  5. troubleshoot Highlight
    By AVM in forum Excel General
    Replies: 2
    Last Post: 05-03-2005, 08:06 PM

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