Hello. I once used the following with Excel 2000
rng = Format(rng)
However, Peter Surcouf suggested using CDbl a while ago here in the
newsgroups.
rng = CDbl(rng)
The both do the same thing. (ie changing 123- to -123, and not changing the
text "test-" to 0 (zero) as using the Val() function would do.)
However, CDbl appears to be faster, especially if the text is really text
that should not be converted to a negative number (ie a cell had "-not a
number-"). My guess is that Format() actually does its thing on each cell,
if it is text or a number. It appears that CDbl can more quickly determine
if the text can be converted. If the data is actually text, it more
quickly moves on and does not bother doing the actual CDbl routine. I am
not an expert, so this is only a guess. Maybe someone can add to this idea.
Anyway, I use the following. I use special cells to only look at text. (no
need to waste time looking at numbers.) I also do not want to look at
formulas. If a Cell had the formula =1 / 3, then using CDbl on this cell
would change the cell to 0.33333333 by replacing the formula with the actual
value. This is probably not what is wanted. Anyway, just another idea to
consider. Dana DeLouis
Sub TrailingMinus()
' = = = = = = = = = = = = = = = =
' General idea from Peter Surcouf
' = = = = = = = = = = = = = = = =
Dim rng As Range
Dim BigRng As Range
On Error Resume Next
Set BigRng = Cells.SpecialCells(xlConstants, xlTextValues).Cells
If BigRng Is Nothing Then Exit Sub
For Each rng In BigRng
rng = CDbl(rng)
Next
End Sub
"Lospanga" <lospa
...@swipnet.se> wrote in message
news:3JYO4.14661$uJ1.31266@nntpserver.swip.net...
> I have a problem. I will try too write as good in english that I can.
> When I import data from a database to Excel - all my negativ numbers is
> converting wrong. All my negative numbert - start with the number and
after
> the number the "negative-character" comes (ex 230-). This is my problem
> because Excel donīt think that my negative numbers are numbers, Excel
think
> that all my negative numbers are text. I want to write all negative
> numbert with the "negative-character" first (ex -230).
> Soo, if somebody know how to write something in VB, that searching for all
> the "negative-character" ( - ) and put the "negative-character" first in
all
> the cell, please help me.
> One more question.....
> Do somebody know who to make one cell "non-printing". I want to see the
> information on the screen but I donīt want the information when I print.
> Madeleine