rounding of numbers in vba

  • Thread starter Thread starter john petty
  • Start date Start date
J

john petty

I have written a program the logs thermal data from a PLC
to a separate excel sheet. The PLC logs the data as a
three place whole number (i.e. 639 = 63.9°F), so I
modified the code to reflect the conversion to a 2 place
decimal(i.e. Tag1 / 10) and formatted the columns to
reflect the same. The problem I have is that when it
throws the data into the sheet, it is rounding the
numbers (i.e 639 =64.00°F). Is there a way that I can
reset this to show the actual (63.9)?


Thanks in advance,

John Petty

P.S. I am using Excel 2002 (XP)
 
Are you sure your variable that holds the data isn't dimmed as long or
integer. Make sure it is double or single.

--
Regards,
Tom Ogilvy

I have written a program the logs thermal data from a PLC
to a separate excel sheet. The PLC logs the data as a
three place whole number (i.e. 639 = 63.9°F), so I
modified the code to reflect the conversion to a 2 place
decimal(i.e. Tag1 / 10) and formatted the columns to
reflect the same. The problem I have is that when it
throws the data into the sheet, it is rounding the
numbers (i.e 639 =64.00°F). Is there a way that I can
reset this to show the actual (63.9)?


Thanks in advance,

John Petty

P.S. I am using Excel 2002 (XP)
 
Are you saving the values in an integer variable before
you put them in the cell? That could be the culprit.
Also are you rounding before you put the values in the
cell in VBA? Try reformating the whole sheet back to
general and then start the formatting over. Hope that
helps.

Keith
www.kjtfs.com
 
Back
Top