bcieszewski
New Member
- Joined
- Feb 13, 2013
- Messages
- 1
Hi
I have a excel spreadsheet produced for KPI tracking purposes. One of the features I added to increase it's usability is "add row" subroutine to prepare a new line for new entry. I can agree for it to run a bit slow when it has to move down around 100 rows of data, but couple of seconds is all I was expecting (I'm running win 7, excell 2010). Unfortunately this macro virtually crashes excel on two other machines, not that much slower than mine but running XP with excel 2010. By crashing I mean taking several minutes to add new line leaving excel unusable for this period of time. I've pasted the code below - perhaps you'll find something that might be optimised and speed up the macro.
I have a excel spreadsheet produced for KPI tracking purposes. One of the features I added to increase it's usability is "add row" subroutine to prepare a new line for new entry. I can agree for it to run a bit slow when it has to move down around 100 rows of data, but couple of seconds is all I was expecting (I'm running win 7, excell 2010). Unfortunately this macro virtually crashes excel on two other machines, not that much slower than mine but running XP with excel 2010. By crashing I mean taking several minutes to add new line leaving excel unusable for this period of time. I've pasted the code below - perhaps you'll find something that might be optimised and speed up the macro.
Code:
Sub SAInsertRow()unlockSheet (password)
Dim v_currentDate As Date
Rows("11").Select 'Selects latest row
ActiveCell.EntireRow.Insert 'Inserts row above the latest
'Start copying data:
v_currentDate = Now
With Range("F11")
.Value = v_currentDate 'date of engagement
.NumberFormat = "m/d/yyyy"
End With
Range("B12:AC12").Copy
Range("B11:AC11").PasteSpecial xlPasteFormats 'copy formats of cells complete
Range("X12:AC12").Copy
Range("X11:AC11").PasteSpecial xlPasteAll 'copy calculations complete
'Copy KPIs
Range("H12").Copy
Range("H11").PasteSpecial xlPasteFormulas
Range("I11").FormulaR1C1 = "=IF(OR(RC[16]=""amber"",RC[16]=""red""),""Enter Comment"","""")" 'copy of Response time complete
Range("L12").Copy
Range("L11").PasteSpecial xlPasteFormulas
Range("M11").FormulaR1C1 = "=IF(OR(RC[16]=""amber"",RC[16]=""red""),""Enter Comment"","""")" 'copy of PM Engagement time complete
Range("P12").Copy
Range("P11").PasteSpecial xlPasteFormulas 'copy of Quality complete
Range("N11").FormulaR1C1 = "=IF(RC[4]=""Closed"",""Add Effort"","""")" 'copy of effort
Range("S11").FormulaR1C1 = "=IF(RC[-1]=""Closed"",""Add Date"","""")" 'copy of SA finished
Range("R12").Copy
Range("R11").PasteSpecial xlPasteValidation 'copy of Status complete
Range("U11").FormulaR1C1 = "=IF(RC[-3]=""On Hold"",""Enter Comment"","""")"
Range("P11").FormulaR1C1 = "=IF(OR(RC[9]=""red"",RC[9]=""amber""),""Enter Comment"","""")"
Application.CutCopyMode = False 'remove "copy" cell border
Range("B11").Activate 'activete project name cell
Range("R11").Value = "Active" 'Set Status to Active
lockSheet (password)
End Sub
Code:
Public Function lockSheet(password)ActiveSheet.Protect password, AllowUsingPivotTables:=True, AllowFiltering:=True
End Function
Code:
Public Function unlockSheet(password)ActiveSheet.Unprotect password
End Function