Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 69
Default VBA Currency datatype and NumberFormat

I use the Currency datatype for decimal numbers. It appears the Currency datatype affects the NumberFormat presentation in Excel. For instance, in my Swedish locale, I get "4,00 kr" rather than "4" as I want. So each time I add something in a cell, I also specify NumberFormat = "General". And it only works if I set NumberFormat *after* setting the cell's value. But when doing that I see a short flicker for each number added, because of the instant change from "4,00 kr" to "4". It works, but the flicker is annoying, and I get a lot of code for each cell. Is there any way to specify that one area has a certain NumberFormat *before* adding data?

Gustaf
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default VBA Currency datatype and NumberFormat

Gustaf

using the value2 property of the range will convert the
variant/currency
before inserting the value, thus preventing the "currency" autoformat.

remember excel uses the double datatype internally.
turn off screenupdating when inserting 30+ numbers..


Sub AddMoney()
Dim sek As Currency
sek = 1234.56

With Range("A1:A2")
.NumberFormat = "general"
.Cells(1).Value = sek
.Cells(2).Value2 = sek
End With
End Sub

--
Jurgen


Gustaf wrote:

I use the Currency datatype for decimal numbers. It appears the
Currency datatype affects the NumberFormat presentation in Excel. For
instance, in my Swedish locale, I get "4,00 kr" rather than "4" as I
want. So each time I add something in a cell, I also specify
NumberFormat = "General". And it only works if I set NumberFormat
after setting the cell's value. But when doing that I see a short
flicker for each number added, because of the instant change from
"4,00 kr" to "4". It works, but the flicker is annoying, and I get a
lot of code for each cell. Is there any way to specify that one area
has a certain NumberFormat before adding data?

Gustaf

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
DateTime datatype in VBA Alex Excel Programming 4 January 30th 07 06:36 PM
Help on Dictionary datatype?? [email protected] Excel Programming 2 January 19th 07 04:38 PM
DataType Property Access101 Excel Programming 3 August 25th 05 08:15 PM
need help- SUB: DATATYPE FOR A CELL.. monika Excel Programming 1 February 13th 04 02:13 PM
DataType Conversion AsimKhaliq Excel Programming 0 January 21st 04 12:40 AM


All times are GMT +1. The time now is 01:13 AM.

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"