View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
Ron Rosenfeld Ron Rosenfeld is offline
external usenet poster
 
Posts: 5,651
Default How to check if cell value is displayed as hashes?

On Sun, 3 Oct 2004 13:39:59 +0100, "RB Smissaert"
wrote:

I have come across one instance where the cell value was something like
6695, no hashes
were displayed, but the instr function found a hash.
Have no idea how this happened, but I didn't think the instr function was
100% foolproof.

RBS


The only way I could get instr to find a hash was if one was displayed in the
cell.

If the cell is date formatted, it can also display a hash if the column is too
narrow.

But you wrote that the cell did NOT display a hash, yet instr found one. I
find that very curious.

Perhaps you can provide enough information to run this down further, as just
putting 6695 in a cell, formatting it as a date, and running the instr test
does not result in instr finding a hash.

If, in fact, the cell is displaying a hash because the cell is too narrow, just
do an autofit before running the instr test.

For example:

=================
Sub foo()
Dim c As Range

Selection.Columns.AutoFit

For Each c In Selection
If InStr(1, c.Text, "#") = 1 Then
MsgBox (c.Text)
End If
Next c

End Sub
=====================




--ron