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

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple

Forum statistics

Threads
1,224,814
Messages
6,181,121
Members
453,021
Latest member
Justyna P

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