VBA crashes Excel

B

Bura Tino

Hi,

The following seemingly innocent routines sometimes crashes excel with one
of those "Send Report" messages. This persists every time Excel is
restarted. Sometimes rebooting the machine helps.

"My Template" is a legitimate hidden worksheet.


Sub gNewSheet()
Dim desiredName As String

desiredName = InputBox("Enter the new portfolio name:", "Sheet Name")

If (desiredName = "") Then
Exit Sub
End If

Sheets("My Template").Copy After:=ActiveSheet
ActiveSheet.Name = Left(desiredName, 31)
ActiveSheet.Range("Response") = ""
ActiveSheet.Range("NameCell") = desiredName

ActiveSheet.Visible = True
End Sub


Many Thanks!

Bura
 
G

GB

Bura

I tried your code on my machine, and the good/bad news is that it all works
perfectly!

I wish I could get it to crash for you. Have you tried your code on another
PC?

Geoff
 
G

GB

Bura - It gets worse! I just added nearly 200 worksheets using your macro,
and it all worked perfectly.

Geoff
 
J

James Cone

Bura,

I see no code to check for invalid characters in the sheet name.
[ ] : / \ * ? are not accepted by Excel in sheet names.
I don't know if entering these characters would crash Excel, but it sure
would cause problems.

Regards,

Jim Cone
San Francisco, CA
*******************
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top