PDA

View Full Version : Info: different Value !



PcMax
04-16-2012, 02:42 AM
Hi,

We are using the following code, run regularly in Excel 2003
The list includes only positive numbers: 12.625

While Excel 2007 does not show the same values ​​...

Any idea? How do I fix these codes?

Any advice is appreciated


'--- Dati -50
Sub Formula()
Dim x As Long
Dim Decurta As Double
Decurta = Sheets("Foglio1").Range("J1").Value
For x = 2 To Range("A" & Rows.Count).End(xlUp).Row
Cells(x, 8).Value = Cells(x, 3) - Decurta
Next
End Sub

'--------- 2 Dec.
Sub Decimali()
Dim x As String

'---Cerco i decimali nella colonna F e copio i valori nella colonna I
With Range("F2:F" & Range("F" & Rows.Count).End(xlUp).Row)
x = .Address
.Offset(, 3) = Evaluate("if(isnumber(" & x & "),round((" & "int(" & x & "* 100" & ")),0)/100," & x & ")")
End With

End Sub

It could be "round(" if the text language is not the same?

Rick Rothstein
04-16-2012, 01:34 PM
Can you show us some examples of values that are not the same in XL2003 and Xl2007 with that code?

PcMax
04-22-2012, 04:13 PM
Hi,

Only now I have understood what were the causes of differences in processing between 2003 and Excel 2007
When retrieving data from the web (an external procedure to excel) I get some values ​​in a column in string format.
The whole column always contains positive values ​​such: 34,12

I checked with a macro ZTEST you can fix it.



Sub Enter_Values()
Dim x As Variant
Dim Xcell As Variant
For Each Xcell In Range("F2:F25000") ' Selection
Xcell.Value = CDec(Xcell.Value)
Next Xcell
End Sub

Sub Decimali()
Dim x As String
With Range("F2:F" & Range("F" & Rows.Count).End(xlUp).Row)
x = .Address
.Offset(, 3) = Evaluate("if(isnumber(" & x & "),round((" & "int(" & x & "* 100" & ")),0)/100," & x & ")")
End With
End Sub

Sub ZTest()
Call Enter_Values
Call Decimali
End Sub

Waiting for suggestions for a better solution!