View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Bernie Deitrick Bernie Deitrick is offline
external usenet poster
 
Posts: 5,441
Default Rescuing Sheets in Corrupt Workbook

Michael,

Try this. For each sheet in your workbook, run the first macro. Then copy the cells and paste as
values into a blank sheet in your new workbook (one for each existing sheet). Then run the second
macro on all sheets in your new workbook. These macros will work on regular formulas, but not
multi-cell or single-cell array formulas.

HTH,
Bernie
MS Excel MVP

Sub FormulaToText()
Dim myCell As Range
Dim myCalc As Variant

With Application
.ScreenUpdating = False
myCalc = .Calculation
.Calculation = xlCalculationManual
.EnableEvents = False
End With

On Error Resume Next

For Each myCell In ActiveSheet.UsedRange.SpecialCells(xlCellTypeFormu las)
myCell.Formula = "'" & myCell.Formula
Next myCell

With Application
.ScreenUpdating = True
.Calculation = myCalc
.EnableEvents = True
End With
End Sub


Sub TextToFormula()
Dim myCell As Range
Dim myCalc As Variant

With Application
.ScreenUpdating = False
myCalc = .Calculation
.Calculation = xlCalculationManual
.EnableEvents = False
End With

On Error Resume Next

For Each myCell In ActiveSheet.UsedRange
myCell.Formula = myCell.Text
Next myCell

With Application
.ScreenUpdating = True
.Calculation = myCalc
.EnableEvents = True
End With
End Sub

"Michael Link" wrote in message
...
I have a workbook which I suspect is corrupt, or at least becoming so: I'm
getting truly funky characters, saved changes don't "stick" when I close out
and open it back up, etc.

I'd like to just move the active sheets out of the current workbook and put
them in a new workbook to see if that helps. My plan was to move them and
then use "Replace" to delete the file path to the original workbook which
Excel inserts into the formulas. Unfortunately, I can't even get to this
point because the appended formulas are too long and get cut off.

Is there a way to tell Excel NOT to update the formulas to include paths to
external workbooks? I need the formulas to be functional in the new workbook,
so I don't want to convert to values only.

Thanks for any help anyone can offer!