Log in

View Full Version : [SOLVED:] My Long is being converted to String (or being Rounded)



TMW949
12-25-2024, 01:47 PM
Function GallonsSinceLastFill() As Long
' Dim FilledCol As Long
Dim GallonsCol As Long
' FilledCol = 9
GallonsCol = 5
GallonsSinceLastFill = Cells(ActiveCell.Row, GallonsCol).Value
MsgBox (ActiveCell.Row & " - " & Cells(ActiveCell.Row, GallonsCol).Value & " - " & GallonsSinceLastFill)
End Function

This is Excel 365 for Mac version 16.92.
The value I am trying to fetch is 9.866 but the function is returning 10.000.
The result from the MsgBox is as follows:
(My file is PDF, so exact content is "unacceptable".) It says:
"282 - 9.866 - 10"
And the Watch says the type is "string * -1"
Can someone please explain why it's doing this (or what I'm doing wrong)?
This may be a Mac problem (sorry for posting here). I'll try Dropboxing it to a Windows machine and see if i works there. I can't see how to upload the simple sample or get the image into the right format.

June7
12-25-2024, 02:09 PM
Long is an integer type. Try declaring the function as Double.

Should be able to attach zip folder. However, I don't know if I could open a Mac generated zip file.

TMW949
12-25-2024, 03:52 PM
Declaring the function as Single seems to work.