View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Sarah H.[_2_] Sarah H.[_2_] is offline
external usenet poster
 
Posts: 48
Default Converting European number formats

Great information from all! Thanks very much, guys. I will be on holiday
the next four or five days, but I'll try the solutions and report here when
I'm back.

Sarah H.
--------------
"Scossa" wrote in message
...
On 26 Ago, 14:02, "Sarah H." wrote:
Hi, all,

I work some with data from Europe and have trouble getting numbers into
U.S.
format.


Try this code (converts european string "1.234,56" into 1234.56 number
value, "52.725" - 52725):


Sub USNumbers2()
' by Scossa
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual

Dim rng As Range
Dim cell As Range
Dim origValue() As String
Dim newValue As String
Dim i As Long

Set rng = Selection.Cells.SpecialCells(xlCellTypeConstants,
xlTextValues)
If Not rng Is Nothing Then
For Each cell In rng
origValue = Split(Replace(cell.Value, ".", ""), ",")
On Error Resume Next 'if no "," in string
newValue = origValue(0)
newValue = newValue & "." & origValue(1)
On Error GoTo 0
cell.Value = CDbl(Trim(newValue))
Next cell
End If
Set rng = Nothing
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub


Tnks for your feedback.

Bye!
Scossa