ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   lost decimal places (https://www.excelbanter.com/excel-programming/275822-lost-decimal-places.html)

GUS

lost decimal places
 
I am using the next code in order to place some values from a list to
cells
the code works fine except if the values has decimal places
When the values are pasted at cells they are loosing their decimal places.


For i = 0 To Me.ListBox1.ListCount - 1
For j = 0 To Me.ListBox1.ColumnCount - 1
Worksheets("TEMPPINAKAS").Cells(i + 2, j + 2).Value =
Me.ListBox1.List(i, j)
Next j
Next i

Any ideas.



Tom Ogilvy

lost decimal places
 
Are your cells formatted to show no decimal places? If you select the cell
and look in the formulabar, does it display the decimal portion?




For i = 0 To Me.ListBox1.ListCount - 1
For j = 0 To Me.ListBox1.ColumnCount - 1
With Worksheets("TEMPPINAKAS")
.Cells(i + 2, j + 2).Value = _
Me.ListBox1.List(i, j)
if instr(Me.Listbox1.List(i,j),".") then
.Cells(i + 2, j + 2).NumberFormat = "General"
end if
End With
Next j
Next i

If your decimal separator is a comma rather than a period (full stop) then
you might need to do

For i = 0 To Me.ListBox1.ListCount - 1
For j = 0 To Me.ListBox1.ColumnCount - 1
With Worksheets("TEMPPINAKAS")
.Cells(i + 2, j + 2).Value = _
cDbl( Me.ListBox1.List(i, j))
end if
End With
Next j
Next i

--
Regards,
Tom Ogilvy



GUS wrote in message
...
I am using the next code in order to place some values from a list to
cells
the code works fine except if the values has decimal places
When the values are pasted at cells they are loosing their decimal

places.


For i = 0 To Me.ListBox1.ListCount - 1
For j = 0 To Me.ListBox1.ColumnCount - 1
Worksheets("TEMPPINAKAS").Cells(i + 2, j + 2).Value =
Me.ListBox1.List(i, j)
Next j
Next i

Any ideas.






All times are GMT +1. The time now is 05:47 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com