inventory adjust code works but it always round up the numbers

AC PORTA VIA

Board Regular
Joined
Apr 9, 2016
Messages
219
Office Version
  1. 365
Platform
  1. Windows
code below that i found on one of the forums works but it always round up or round down numbers
if i have 21.66 and add 2.22 it should be 23.88 but it shows 23.66
VBA Code:
Sub Add_to_Inventory()
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
Application.DisplayStatusBar = False
Application.EnableEvents = False
Sheets("ADJUST").Unprotect
Sheets("INVENTORY").Unprotect
Dim i As Long, qty As Long, sku As String, fnd As Range
With Sheets("ADJUST")
   For i = 2 To .Cells(.Rows.Count, 2).End(xlUp).Row
        sku = .Range("A" & i): qty = .Range("F" & i)
        With Sheets("Inventory")
            Set fnd = .Range("O:O").Find(sku, LookIn:=xlValues, lookat:=xlWhole)
            If Not fnd Is Nothing Then
                fnd.Offset(, 6) = fnd.Offset(, 6) + qty '! To remove from inventory change + to -
            End If
        End With
    Next i
End With
    Range("D2:D200").ClearContents
    Range("F2:F200").ClearContents
Sheets("ADJUST").Protect
Sheets("INVENTORY").Protect
Application.ScreenUpdating = True
Application.DisplayStatusBar = True
Application.EnableEvents = True
Application.Calculation = xlCalculationAutomatic
End Sub
 
Last edited:

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
The 'qty' variable is a Long type which is whole numbers. Try changing it to a Double.
 
Upvote 0
Solution

Forum statistics

Threads
1,215,617
Messages
6,125,867
Members
449,266
Latest member
davinroach

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