+ Reply to Thread
Results 1 to 4 of 4

Macro Takes 1 hour to run...

  1. #1
    Registered User
    Join Date
    08-07-2016
    Location
    Athlone, Westmeath
    MS-Off Ver
    2013
    Posts
    11

    Macro Takes 1 hour to run...

    Hey All,
    Looking for a bit of help to speed up a macro if at all possible. At the minute it takes approx. 30 seconds per line it has to copy. Some of the sheets could have 100 lines to copy so waiting nearly an hour isn’t ideal.
    The code I have is below. Column A on the Active Sheets is populated by “=COUNTIFS('Tax Payover'!S:S,G14,'Tax Payover'!V:V,J14)+IF(AV14>0,"1","0")” G is a Unique identifier, J is a code and AV is a Tax Value.

    Sub CopyTax()
    Dim LR1 As Long, Cell As Range, matchRow As Long
    With Sheets("Tax Payover")
    LR1 = .Range("O" & .Rows.Count).End(xlUp).Row + 1

    For Each Cell In Sheets(ActiveSheet.Name).Range("A:A")
    If Cell.Value = "1" Then
    matchRow = Cell.Row
    Intersect(Sheets(ActiveSheet.Name).Rows(matchRow), Sheets(ActiveSheet.Name).Columns("B:AW")).Copy .Range("N" & LR1)
    LR1 = LR1 + 1
    End If
    Next
    End With
    End Sub


    I hope this is all the information you need. If not let me know what I am missing and I will update.

    Thanks for the Help.
    John

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,413

    Re: Macro Takes 1 hour to run...

    This
    Please Login or Register  to view this content.
    says loop through every cell in column A. That's over a million cells. Maybe that could be it?
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: Macro Takes 1 hour to run...

    Agreed with @TMS, but in addition, you don't need to evaluate every cell for "1".

    Simply filter for "1", block copy all of those cells, them move on to the next sheet. It shouldn't take more than a minute to run.

    If you provide a sample workbook (with just a few sheets of dummy data formatted in an identical manner to your real workbook), I can provide some code.
    I'm interested in starting a career working with VBA, if anyone knows of any opportunities!

  4. #4
    Registered User
    Join Date
    08-07-2016
    Location
    Athlone, Westmeath
    MS-Off Ver
    2013
    Posts
    11

    Re: Macro Takes 1 hour to run...

    Hey Guys,
    Sorry for the delay in replying. I managed to sort it by disabling things like formula, page break updates etc until the macro ran. Only takes 15-20 seconds now.
    Thanks for your suggestions though.

+ 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. Excel takes over an hour to calculate !!!
    By Smudge.Smith in forum Excel General
    Replies: 5
    Last Post: 11-25-2015, 01:29 PM
  2. Is it normal that this macro takes so much time?
    By tsakta13ole in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-31-2015, 04:53 AM
  3. VBA Script to run a macro on the hour every hour
    By warmajam in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-14-2014, 11:24 AM
  4. [SOLVED] Formula that takes takes out a specific word/number from text string
    By ncalvelo in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 11-29-2012, 10:21 AM
  5. Worksheet change macro takes too much time when run with update list macro
    By hunsnowboarder in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-01-2009, 09:40 AM
  6. how do i add time to see how long my macro takes to run
    By ernestgoh in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-16-2006, 06:10 AM
  7. [SOLVED] Counting how long a Macro takes to run
    By Diane Alsing in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-07-2005, 02:06 PM

Tags for this Thread

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