automatic rounded up value

khatri milan

New Member
Joined
Nov 6, 2019
Messages
17
i am using following vba code to put data from a table in one worksheet into another worksheet, it is working fine except that the value are geting rounded up to nearest integer(37.53 to 38.00).I checked its format too ,it is set for two points after decimal . why is it geting rounded up automatically? Is it because i have defined vaiable as long?

Dim dia As Long
Dim maxcap As Long
Dim m As Integer
Dim n As Integer
For m = 74 To 76
For n = 4 To 22
maxcap = Worksheets("9_Sling Data").Range("c" & n).Value
If maxcap > Range("i" & m).Value Then
Range("h" & m).Value = maxcap
dia = Worksheets("9_Sling Data").Range("i" & n).Value
Range("g" & m).Value = dia
Range("j" & m).Value = Round(Range("i" & m).Value / Range("h" & m).Value, 2)
Range("c" & m).Value = n
Exit For
Else
End If
Next n
Next m
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off

Forum statistics

Threads
1,215,032
Messages
6,122,772
Members
449,095
Latest member
m_smith_solihull

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top