+ Reply to Thread
Results 1 to 5 of 5

Code needs cleaning up

  1. #1
    Registered User
    Join Date
    10-30-2008
    Location
    AL
    Posts
    27

    Code needs cleaning up

    The below code is something I've inherited and I'm pretty sure it's a complete mess. I would really like to clean it up by removing anything unecessary or redundant. My ultimate goal is to make this code much shorter and more efficient. But alas, I'm a novice with this kind of stuff.

    Any help is greatly appreciated.

    Please Login or Register  to view this content.
    Thanks guys

  2. #2
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Code needs cleaning up

    Try this to start with
    Check it does the same, I might have got a bit lost.

    [EDIT]
    code revisited after comments in Post #3
    Please Login or Register  to view this content.

    Check your formulae, I can't confirm they do as you want.
    Also
    Check your sort criteria

    Hope this helps
    Last edited by Marcol; 07-09-2010 at 10:37 AM. Reason: Avoiding clutter and removing useless code

  3. #3
    Registered User
    Join Date
    10-30-2008
    Location
    AL
    Posts
    27

    Re: Code needs cleaning up

    Thanks Marcol. I appreciate your help.

    When I run your macro, a couple of things happen:

    The second line of the code (Range("G2").....) pastes the values in Sheet 2, which is where a form button is located with this macro assigned to it.

    Also, as the macro is running, it tries to open a file three different times and I'm afraid I don't have any idea what would cause that.

    Again, thanks for your help.

  4. #4
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Code needs cleaning up

    Got to break a while I'll check later.

  5. #5
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Code needs cleaning up

    1/.
    The second line of the code (Range("G2").....) pastes the values in Sheet 2, which is where a form button is located with this macro assigned to it.
    That's where you ask for it to go! Shift the button, or change the destination cell.

    2/.
    as the macro is running, it tries to open a file three different times
    Check the number of times your formulae calls 'Sheet 1' instead of 'Sheet1', this looks like the source of this error.

    Rather than clutter the BB with useless code, I have edited Post #2.
    I have corrected what I see as errors, and simplified as much as I can confidentlly can.

    Check that revised code out

    Hope this helps
    If you need any more information, please feel free to ask.

    However,If this takes care of your needs, please select Thread Tools from menu above and set this topic to SOLVED. It helps everybody! ....

    Also
    اس کی مدد کرتا ہے اگر
    شکریہ کہنے کے لئے سٹار کلک کریں
    If you are satisfied by any members response to your problem please consider using the small Star icon bottom left of their post to show your appreciation.

+ 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