Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default A visual basic value copy BUG?? - accounting format has copy problem!!

Wow Peter~! Thanks a lot! That ".value2" works amazingly fine!!
Thanks a million for the tip.

Peter T wrote:
This relates to Excel's automatic conversion of dates & currencies, which
gets it right for users 'most' of the time.

dim cur as currency
cur = 0.0123
[c4]=cur ' 0.01
[c5] = cdbl(cur) ' 0.0123

back to your issue, you'll note when you did -
Range("A2:B2").Value = Range("A1:B1").Value

that A2 is automatically formatted as currency, because the data type
(VarType) of that element in the array is currency.

You could do -
Range("A2:B2").Value = Range("A1:B1").Value2

which will place the intrinsic values but won't change the existing format.

Regards,
Peter T

wrote in message
oups.com...
I just got an unbelievable behavior from excel when i did the following
value copying:
-----------------------------
Sub mycopy()
Range("A2:B2").Value = Range("A1:B1").Value
End Sub
-----------------------------

I formatted cell A1 as accounting format (or currency format $) and
input $0.0123 in A1.
format cell B1 as general format and input 0.0123 into B1.

After running the macro, you'll see the target values of A2 becomes
$0.0100, B2 is 0.0123. (i'm using excel 2003)

THe accounting/currency format just use the rounding automatically!!!
Is this a bug? or a feature?

BTW, i tried after to use ".copy" and ".PasteSpecial xlPasteValues",
that works regardless. But not knowing the limit of range copy made
million dollar difference in my analysis! DARN it!


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
visual basic. find copy row past into new sheet Chuck Excel Worksheet Functions 3 December 17th 07 09:02 PM
If match copy cells in visual basic. thomsonpa New Users to Excel 3 December 13th 07 05:14 PM
copy and paste (visual basic) ian123 New Users to Excel 1 June 8th 06 12:22 AM
visual basic (copy and paste) ian123 Excel Worksheet Functions 2 June 7th 06 11:26 PM
copy and paste (visual basic) ian123[_52_] Excel Programming 1 June 7th 06 11:20 PM


All times are GMT +1. The time now is 10:55 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"