[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:
Sub Start()
Dim iSheet As Worksheet
Dim kSheet As Worksheet
Dim n As Long
Dim j As Long
Application.ScreenUpdating = False
Set iSheet = ActiveWorkbook.Sheets("Input")
Set kSheet = ActiveWorkbook.Sheets("Konstante")
For n = 1 To 15000
For j = 1 To 300
If kSheet.Cells(j, "A").Value = iSheet.Cells(n, "M").Value Then
iSheet.Cells(n, "N").Value = kSheet.Cells(j, "B").Value
End If
If kSheet.Cells(j, "A").Value = iSheet.Cells(n, "N").Value Then
iSheet.Cells(n, "O").Value = kSheet.Cells(j, "B").Value
End If
If kSheet.Cells(j, "A").Value = iSheet.Cells(n, "F").Value Then
iSheet.Cells(n, "P").Value = kSheet.Cells(j, "B").Value
End If
If kSheet.Cells(j, "C").Value = iSheet.Cells(n, "F").Value Then
iSheet.Cells(n, "AF").Value = kSheet.Cells(j, "D").Value
End If
iSheet.Cells(n, "AG").Value = iSheet.Cells(n, "AE").Value & iSheet.Cells(n, "AF").Value
If kSheet.Cells(j, "A").Value = iSheet.Cells(n, "AG").Value Then
kSheet.Activate
kSheet.Range(Cells(j, "B"), Cells(j, "O")).Copy
iSheet.Activate
iSheet.Range(Cells(n, "Q"), Cells(n, "AD")).PasteSpecial Paste:=xlValues
Application.CutCopyMode = False
End If
Next j
Next n
Set iSheet = Nothing
Set kSheet = Nothing
Application.ScreenUpdating = True
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
Re: [Resolved]Speeding it up?!?
Glad to hear you got it working. If you wanted to expend more energy, you might be able to get some incremental improvements by, for example, using Integer instead of Long for the index (keeping in mind the comments by Webtest), and/or implementing speed tips such as ones found:
http://www.vbforums.com/showthread.php?t=264351
http://www.aivosto.com/vbtips/stringopt.html
http://www.planet-source-code.com/vb...34787&lngWId=1
http://www.persistentrealities.com/v...egory=1&item=0