View Single Post
  #2   Report Post  
Dave O
 
Posts: n/a
Default

Here's a solution for you. Step 1, of course, is to make a backup copy
of your data so you don't lose anything! Then copy this code, and
paste it in as a macro.

It stores the value of each cell to memory if the cell does not contain
a formula, deletes the contents of the cell, and rewrites the stored
value into the cell.

Sub TrueVal_Tab()
'Converts apparently non-blank cells, such as those containing
'spaces or an apostrophe, to blank cells in the current tab of
'a workbook. Useful for data imported from a database.

'Use and distribute freely. If you find this useful, and particularly
'if you are in a corporate setting and this bails you out of a serious
'jam, ask your company to make a donation to the American Diabetes
'Association, or the national Diabetes Foundation in your country.

'Set calc to manual
With Application
..Calculation = xlManual
..MaxChange = 0.001
End With
ActiveWorkbook.PrecisionAsDisplayed = False

Dim TrueVal
Dim Rows As Long, Columns As Long
Dim R As Long, C As Long

'determine lower right corner of this tab
ActiveCell.SpecialCells(xlLastCell).Select
Rows = Selection.Row
Columns = Selection.Column
'return to a1
Range("a1").Select

'Begin FOR loop to cycle through columns and rows
For C = 0 To Columns - 1
For R = 0 To Rows - 1

'if the cell contains a formula, skip
If Len(ActiveCell.Offset(R, C).Formula) 0 Then GoTo Bailout:
TrueVal = Trim(ActiveCell.Offset(R, C).Value)
ActiveCell.Offset(R, C).Value = ""
ActiveCell.Offset(R, C).Value = TrueVal

Bailout:
Next R
Next C

'set calc to auto
With Application
..Calculation = xlAutomatic
..MaxChange = 0.001
End With
ActiveWorkbook.PrecisionAsDisplayed = False

Calculate
End Sub