Need a work around!!

MsAlitaY

New Member
Joined
Jul 19, 2016
Messages
4
Hi All,

The code below reviews each row and returns "ERROR" in column P if the sum of the MONTHS does not equal the hard number stated in YTD; if the numbers match the code just moves on to the next row for evaluation.

The code works perfectly EXCEPT when the sum total and the YTD ends with .50...urg!!! ANY IDEAS ON HOW TO FIX THIS???

OFFSET
-15
-14
-13
-12
-11
-10
-9
-8
-7
-6
-5
-4
-3
-2
-1
ACTIVECELL
COLUMN
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Business Unit
Fund
Department
Major
Account
Title
FY16
FY17
JUL
AUG
SEP
OCT
NOV
YTD
BUDGET
Error Check
95720
01000
857
11
5012489
Expense
59,803.08
62,734.25
8,001.36
5,456.20
5,456.20
5,459.90
5,615.84
29,989.50
70,951.00
ERROR

<tbody>
</tbody>

'To review each row for data errors

Do While ActiveCell.Offset(0, -11).Value > 0
YTD = ActiveCell.Offset(0, -2)
Fx = Application.WorksheetFunction.Sum(ActiveCell.Offset(0, -7), ActiveCell.Offset(0, -6), ActiveCell.Offset(0, -5), ActiveCell.Offset(0, -4), ActiveCell.Offset(0, -3))

If Fx = YTD Then

ActiveCell.Offset(1, 0).Select

Else

Range("P1").FormulaR1C1 = "Error Check"
ActiveCell.FormulaR1C1 = "ERROR"
ActiveCell.Offset(1, 0).Select

End If

Loop
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
I am guessing that you may have declared either your YTD or Fx variables in VBA to be Integers. Note that Integers do not allow for decimals!
You will need to change how they are declared (maybe Single or Double).
 
Upvote 0
You are welcome.

Yep, "Long" is short for "Long Integer", another data type with no decimals.
 
Upvote 0

Forum statistics

Threads
1,215,364
Messages
6,124,507
Members
449,166
Latest member
hokjock

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