Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Macro bombing Excel 2002 sp2 when trying to save

Status
Not open for further replies.

towntopic

Technical User
May 15, 2003
103
US
I've written a macro so that a user can select cells and then convert any text within the cells to upper case. If I close out of the macro editor instead of saving, I notice the macro runs perfectly. BUT, my problem is anytime I try to save the workbook the program hard crashes and restores itself without any of the macros I've written for it.

Here is the macro...any ideas as to why this would cause Excel to bomb. I'm saving as Microsoft Excel 97-2002 & 5.0/95 Workbook.

Sub UpperCase()
Dim cell As Range

'Ask if the user has the correct range selected

Response = MsgBox("Have you selected the cell to convert to Upper Case?", vbYesNo, "Convert to Upper Case")
If Response = vbNo Then ' User chose No.
End
Else ' User chose No.
End If

For Each cell In Selection.Cells
If cell.HasFormula = False Then ' Do not convert case if cell has a formula
cell = UCase(cell) ' Force upper case
End If
Next
End Sub



Thanks for any help.
 
Not positive this is your problem, but using "cell" as a variable is a bad idea. Try using a variable like "C" or "TargetCell". . .

VBAjedi [swords]
 
If I save the file as a .xls instead of the Microsoft Excel 97-2002 & 5.0/95 Workbook format it works just fine. Strange....using the variable "C" didn't prevent it from bombing upon saving.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top