VBA Question

Utterly Bamboozled

New Member
Joined
Jul 7, 2010
Messages
39
Could someone please tell me why this code keeps crashing Excel??

'
Sheets("Timesheet").Select
Sheets("Timesheet").Copy Before:=Sheets(5)
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Timesheet (2)").Select
Sheets("Timesheet (2)").Name = Range("C6").Value
Range("C6:E6").Select
Application.CutCopyMode = False
End Sub

Thanks!
 
Code:
Sub Export()
    
    [COLOR="Red"]Dim nm As Name[/COLOR]
    
    Sheets("Timesheet").Copy Before:=Sheets(5)
    
    ActiveSheet.Unprotect Password:="Secret"
    ActiveSheet.UsedRange.Value = ActiveSheet.UsedRange.Value
[COLOR="Red"]    For Each nm In Names
        If nm.Parent.Name = ActiveSheet.Name Then nm.Delete
    Next nm[/COLOR]
    
    On Error Resume Next
    ActiveSheet.Name = Range("C6").Text
    On Error GoTo 0
    
    If ActiveSheet.Name <> Range("C6").Text Then MsgBox "Couldn't rename the sheet as " & Range("C6").Text
    
    ActiveSheet.Range("C6:E6").Select
    
End Sub
 
Upvote 0

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.

Forum statistics

Threads
1,224,607
Messages
6,179,871
Members
452,949
Latest member
Dupuhini

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