+ Reply to Thread
Results 1 to 2 of 2

Improve working, but inefficient code

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    07-21-2010
    Location
    Alta, Norway
    MS-Off Ver
    Excel 2003
    Posts
    119

    Improve working, but inefficient code

    Hi all,

    I use the following code:

    Sub bvlasdflkas()
    
    cellerSomSkalFylles = 45269
    cellerSomSkalSøkesGjennom = 17752
    ScreenUpdating = False
    'ScreenUpdating = False
    For f = 2 To cellerSomSkalFylles
    DAGEN = 0
    For i = 4 To cellerSomSkalSøkesGjennom
    With Worksheets("No of shares")
    If .Cells(i, 3).Text = Worksheets("Test").Cells(f, 4).Text And .Cells(i, 4).Text <= Worksheets("Test").Cells(f, 1).Text Then
        If .Cells(i, 4).Value >= DAGEN Then
            Worksheets("Test").Cells(f, 7).Value = .Cells(i, 5).Value
            DAGEN = .Cells(i, 4).Value
            'MsgBox "BALLE"
        End If
    End If
    End With
    Next
    'MsgBox "pung"
    Next
    
    ScreenUpdating = True
    End Sub
    It works, but it would take about a week to let it run through:p
    I am no expert in writing codes, and would be most greatful if somecould could assist me in rewriting it into a more efficient code

    Gnoke

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,523

    Re: Improve working, but inefficient code

    Possibly a Filter macro for each sheet instead of looping through 18k rows would make a big difference.
    No way to tell without a sample worksheet though.

+ 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