VBA Macro Breaks Excel 2003

TechTank

Board Regular
Joined
Sep 5, 2011
Messages
92
Hi All,

First post so please be gentle :) I've written the following macro to insert a row, copy some cells from another sheet and then paste them into the new row. The problem occurs when I use this macro more than once it crashes Excel 2003 out! Any help greatly appreciated:

### Code Begins ###

Option Explicit
Option Compare Text
Sub InsertRow()
Dim rFind As Long
On Error Resume Next

'Disables Sheet Protection
ActiveSheet.Unprotect

'Stop Updating of The Screen To Optimise Speed
Application.ScreenUpdating = False

'Prevent Prompting
Application.DisplayAlerts = False

'If rFind > 0 Then Rows(rFind + 1).Insert xlShiftDown
'Selects Entire Last Row
Sheets("Format Control").Select
Rows("3:3").Select

'Copies Entire Last Row
Selection.Copy

'Selects the Environment Information Sheet
Sheets("Environment Information").Select

rFind = Columns("A:A").Find(What:="0", After:=Range("A5"), LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False).Row

If rFind > 0 Then Rows(rFind + 1).Insert xlShiftDown

'Enable Prompting
Application.DisplayAlerts = False

'Update The Screen
Application.ScreenUpdating = True

'Enables Sheet Protection
'ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _

ActiveCell.Offset(4, -3).Select

End Sub

### Code Ends ###


My knowledge of VBA is minimal to be honest but if anyone has any suggestions I would be very grateful.

*Edit* I've just had an error appear from 'Microsoft Visual Basic' stating 'Automation Error'. This doesn't seem to affect any other macros in this workbook and there are a few.

Thank you all for your time.
 
Last edited:
You are welcome

Oman is still nice - just starting to cool down now - 38 today and 26 tonight!

Still sounds a little too hot for me! :) It's on my list of places to re-visit but I loved the 8 hour or so drive through the desert to Thumrait and the pure dark sky so that you can see the Milky Way so clearly. Truly awe inspiring.
 
Upvote 0

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.

Forum statistics

Threads
1,223,270
Messages
6,171,102
Members
452,379
Latest member
IainTru

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