View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Gary''s Student Gary''s Student is offline
external usenet poster
 
Posts: 11,058
Default Number stored as text. How do I keep the number format?

Format the destination cell as text prior to running the macro.
--
Gary's Student


"staying" wrote:


Hi, all.

I came across a problem when trying to put a value from one cell to
another.
Here goes a sample code.

=======================
Sub aaa()
Dim rng_src as range

Set rng_src = activecell
activecell.offset(1,0).value = rng_src.value
activecell.offset(1,0).NumberFormat = rng_src.NumberFormat

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

It works fine with regular numeric or string values, but gets very
frustrating when the source cell is "number stored as text", whether
the cell format was overriden with an apostrophe or it was value-copied
from such ranges.

I can't find anything in the vba help file or the object browser.

Is there any way to work around this pain in the 's' , other than
PasteSpecial method?

Thanks a lot.


--
staying
------------------------------------------------------------------------
staying's Profile: http://www.excelforum.com/member.php...o&userid=23230
View this thread: http://www.excelforum.com/showthread...hreadid=550888