First, here's a post that I saved.
It could mean a few things.
1. The columnwidth is too narrow to show the number.
Widen the column or change the font size of that cell. Or change the
numberformat to General.
2. You have a date/time in that cell and it's negative
Don't use negative dates. If excel was helping you, it may have
changed the format to a date. Change it back to General (or some
other number format).
If you need to see negative date/times:
Tools|options|Calculation Tab|and check 1904 date system
(but this can cause trouble--watch what happens to your dates
and watch what happens when you copy|paste dates to a different
workbook that doesn't use this setting)
3. You have a lot of text in the cell, the cell is formatted as Text.
Format the cell as general.
4. You really have ###'s in that cell.
Clean up that cell.
5. You have # in a cell, but it's format is set to Fill.
Change the format
(format|cells|alignment tab|horizontal box, change it to General.
============
This code will try to fix problems 1 and 3. If you have others, then the
program will continue to find the offending cell, fail to fix it and end up in
an endless loop.
So you may want to add more checks to this code...
Option Explicit
Sub testme01()
Dim wks As Worksheet
Dim FoundCell As Range
Dim FirstAddress As String
Set wks = ActiveSheet
With wks
Set FoundCell = .Cells.Find(what:="#", _
after:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False, _
SearchFormat:=False)
If FoundCell Is Nothing Then
MsgBox "None found!"
Exit Sub
End If
FirstAddress = FoundCell.Address
Do
If Replace(FoundCell.Text, "#", "") = "" Then
If Application.IsNumber(FoundCell.Value2) Then
FoundCell.EntireColumn.AutoFit
Else
If FoundCell.NumberFormat = "@" Then
If Len(FoundCell.Value) > 255 _
And Len(FoundCell.Value) < 1025 Then
FoundCell.NumberFormat = "General"
End If
End If
End If
End If
Set FoundCell = .Cells.FindNext(after:=FoundCell)
If FoundCell Is Nothing Then
Exit Sub
End If
If FoundCell.Address = FirstAddress Then
Exit Sub
End If
Loop
End With
End Sub
If you're new to macros:
Debra Dalgleish has some notes how to implement macros here:
http://www.contextures.com/xlvba01.html
David McRitchie has an intro to macros:
http://www.mvps.org/dmcritchie/excel/getstarted.htm
Ron de Bruin's intro to macros:
http://www.rondebruin.nl/code.htm
(General, Regular and Standard modules all describe the same thing.)