Results 1 to 22 of 22

Thread: [Resolved]Speeding it up?!?

Threaded View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2006
    Posts
    96

    Resolved [Resolved]Speeding it up?!?

    Hi all you wiz'es

    I'm done with a macro at work, but need to test it completely with different values and options in the sheet - however this takes a LONG time since my macro is running on brute force!

    VB Code:
    1. Sub Start()
    2. Dim iSheet As Worksheet
    3. Dim kSheet As Worksheet
    4. Dim n As Long
    5. Dim j As Long
    6.    
    7. Application.ScreenUpdating = False
    8.    
    9.     Set iSheet = ActiveWorkbook.Sheets("Input")
    10.     Set kSheet = ActiveWorkbook.Sheets("Konstante")
    11.    
    12.     For n = 1 To 15000
    13.         For j = 1 To 300
    14.             If kSheet.Cells(j, "A").Value = iSheet.Cells(n, "M").Value Then
    15.                 iSheet.Cells(n, "N").Value = kSheet.Cells(j, "B").Value
    16.             End If
    17.             If kSheet.Cells(j, "A").Value = iSheet.Cells(n, "N").Value Then
    18.                 iSheet.Cells(n, "O").Value = kSheet.Cells(j, "B").Value
    19.             End If
    20.             If kSheet.Cells(j, "A").Value = iSheet.Cells(n, "F").Value Then
    21.                 iSheet.Cells(n, "P").Value = kSheet.Cells(j, "B").Value
    22.             End If
    23.             If kSheet.Cells(j, "C").Value = iSheet.Cells(n, "F").Value Then
    24.                 iSheet.Cells(n, "AF").Value = kSheet.Cells(j, "D").Value
    25.             End If
    26.             iSheet.Cells(n, "AG").Value = iSheet.Cells(n, "AE").Value & iSheet.Cells(n, "AF").Value
    27.             If kSheet.Cells(j, "A").Value = iSheet.Cells(n, "AG").Value Then
    28.                 kSheet.Activate
    29.                 kSheet.Range(Cells(j, "B"), Cells(j, "O")).Copy
    30.                 iSheet.Activate
    31.                 iSheet.Range(Cells(n, "Q"), Cells(n, "AD")).PasteSpecial Paste:=xlValues
    32.                 Application.CutCopyMode = False
    33.             End If
    34.         Next j
    35.     Next n
    36.        
    37.     Set iSheet = Nothing
    38.     Set kSheet = Nothing
    39.  
    40. Application.ScreenUpdating = True
    41. End Sub

    The final macro is made up with 12 of these subcommands and a complete test takes 6500 secs! (that's 1h 48m 20s!!) - since I need to test it with a lot of different combinations I would like to speed up the process!

    Is this possible??

    thanx
    /nick
    Last edited by direktoren; Mar 13th, 2006 at 03:37 AM. Reason: question solved

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width