+ Reply to Thread
Results 1 to 9 of 9

Long code takes an age to run

  1. #1
    Registered User
    Join Date
    07-20-2009
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    63

    Talking Long code takes an age to run

    Hi

    I have the following code: Which when its run it looks in AC for a value i.e RDA Uk and when it finds it it copies the row and then pastes in "UK". It will continue until it finds "", then it will move on to the next value and do the same again. I have 6/7 values to find and move to another sheet.

    Can anyone help edit to code to help the macro to run quicker?

    Please Login or Register  to view this content.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Long code takes an age to run

    One of the main problems is that you are selecting ranges, this is not necessary.
    You are alos using a loop to find the next blank cell, again time consuming.
    You are using a loop to copy individual rows, it would be more efficient to copy a block of rows.

    Attach an example workbook
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    07-20-2009
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    63

    Re: Long code takes an age to run

    Getting a error when i'm trying to up load, i will try again soon

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Long code takes an age to run

    The file may be to big, try zipping it

  5. #5
    Registered User
    Join Date
    07-20-2009
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    63

    Re: Long code takes an age to run

    I get the following:
    Database error
    The Excel Help Forum database has encountered a problem.

    --------------------------------------------------------------------------------

    Please try the following:
    Load the page again by clicking the Refresh button in your web browser.
    Open the www.excelforum.com home page, then try to open another page.
    Click the Back button to try another link.

    The www.excelforum.com forum technical staff have been notified of the error, though you may contact them if the problem persists.

    We apologise for any inconvenience

  6. #6
    Registered User
    Join Date
    07-20-2009
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    63

    Re: Long code takes an age to run

    Please find sample work book attached
    Attached Files Attached Files

  7. #7
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Long code takes an age to run

    Based on your file perhaps try something along the lines of the below, note however I created a sheet ROM for Romania data as this was not present originally.

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    07-20-2009
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    63

    Re: Long code takes an age to run

    Thanks very much for your help.

    The reason there is no Romaina is because it goes in with the CE Region. Also this code works for all apart from UK.

  9. #9
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Long code takes an age to run

    The reason there is no Romaina is because it goes in with the CE Region.
    OK, so change the associated sheet in vSheets from ROM to CE.
    (you could store a listing of regions and appropriate sheet in a table somewhere if preferred)

    Also this code works for all apart from UK.
    Worked for me in the sample file.... though I should have added the code is based on the assumption that the various regions (RDA UK etc) are grouped together on Combined (ie not broken up RDA UK, RDA Benelux, RDA UK etc...) ... if not it would be worth switching to a Filter based iteration.

+ 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