Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I just wrote the following code to convert hours and minutes to decimal
numbers. This is a test run to prepare for the real deal so it's kind of ugly. The problem is that the variable "min" which is declaired as a LONG is only giving me back whole numbers. What do I do to stop that??? Thanks in advance - Pikus Private Sub Test_Click() Dim wd As String Dim time As Long Dim hr As Long Dim min As Long wd = "Saturday" Do y = y + 1 Loop Until Worksheets(wd).Cells(y + 1, 1).Value = "" For x = 1 To y Worksheets(wd).Cells(x, 4).Value = "=HOUR(C" & x & ")" hr = Worksheets(wd).Cells(x, 4).Value Worksheets(wd).Cells(x, 5).Value = "=MINUTE(C" & x & ")" min = Worksheets(wd).Cells(x, 5).Value min = min / 60 Worksheets(wd).Cells(x, 6).Value = min time = hr + min Worksheets(wd).Cells(x, 7).Value = time Next x End Sub --- Message posted from http://www.ExcelForum.com/ |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Long is an expanded form of Integer. For greater precision you need to use
Single or Double. -- Vasant "pikus" wrote in message ... I just wrote the following code to convert hours and minutes to decimal numbers. This is a test run to prepare for the real deal so it's kind of ugly. The problem is that the variable "min" which is declaired as a LONG is only giving me back whole numbers. What do I do to stop that??? Thanks in advance - Pikus Private Sub Test_Click() Dim wd As String Dim time As Long Dim hr As Long Dim min As Long wd = "Saturday" Do y = y + 1 Loop Until Worksheets(wd).Cells(y + 1, 1).Value = "" For x = 1 To y Worksheets(wd).Cells(x, 4).Value = "=HOUR(C" & x & ")" hr = Worksheets(wd).Cells(x, 4).Value Worksheets(wd).Cells(x, 5).Value = "=MINUTE(C" & x & ")" min = Worksheets(wd).Cells(x, 5).Value min = min / 60 Worksheets(wd).Cells(x, 6).Value = min time = hr + min Worksheets(wd).Cells(x, 7).Value = time Next x End Sub --- Message posted from http://www.ExcelForum.com/ |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
DOH!
Damn. You're right. I feel like an idiot. Thanks very much. - Pikus ![]() --- Message posted from http://www.ExcelForum.com/ |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Accuracy | Excel Discussion (Misc queries) | |||
Convert Lats and longs to decimals | Excel Worksheet Functions | |||
convert lats and longs to decimals | Excel Worksheet Functions | |||
Data Accuracy | Excel Discussion (Misc queries) | |||
Accuracy | Excel Programming |