Add new line macro runs slow on certain machines

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.

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
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)

Forum statistics

Threads
1,215,639
Messages
6,125,971
Members
449,276
Latest member
surendra75

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top