Hi there, I'm creating a game in excel - I'm pretty new to vba code writing and have come across a problem that has me stumped...
I have some code as follows which takes approx. 30 seconds to run (ALLENEMYMOVE). However when I Call this at the end of another macro (AFTERFIGHTTOHOME) the same code now takes approx 5 mins to run. The cells altered by the (AFTERFIGHTTOHOME) macro do not affect the (ALLENEMYMOVE) macro so not sure what the difference is - if I run the two parts of code separately they execute quickly but putting them together seems to decrease the speed substantially. Any ideas why this is or how to get round this? Many thanks,
Theo
Sub ALLENEMYMOVE()
' ALLENEMYMOVE Macro
'
'Zap location of home armies
EnableEvents = False
Call ACTIVEROWCOLUMN3
Sheets("Map").CALCULATE
Dim No_of_Times_to_Repeat As Integer
Dim i As Integer
No_of_Times_to_Repeat = Sheets("Arena").Range("CN2").Value
'No_of_Times_to_Repeat = 1
For i = 1 To No_of_Times_to_Repeat
'Choose next army
If Sheets("Arena").Range("CO" & (i + 6)).Value <> "X" Then
Sheets("Arena").Range("CM5").Value = Sheets("Arena").Range("CM" & (i + 6)).Value
Sheets("Arena").Range("DL5").Value = Sheets("Arena").Range("DL4").Value
Sheets("Arena").CALCULATE
Call ENEMYMOVE
End If
Next i
Range("A1").Select
EnableEvents = True
End Sub
Sub AFTERFIGHTTOHOME()
'
' AFTERFIGHTTOHOME Macro
Sheets("Home").Range("C2:H16").Value = Sheets("Home").Range("CD2:CI16").Value
Sheets("Home").Range("BF2:BK16").Value = Sheets("Home").Range("CJ2:CO16").Value
Sheets("Home").Range("BN2:BN16").Value = Sheets("Home").Range("CP2:CP16").Value
Sheets("Map").Select
Range("A1").Select
Range("CH36") = 0
CALCULATE
Call ALLENEMYMOVE
End Sub
Bookmarks