VBA less than operator not working as expected

dbroosk87

New Member
Joined
Jun 12, 2013
Messages
4
I'm not really sure what is happening here. I got this data from a larger macro that connects to a SQL database, sums up a bunch of values, then tests for whether or not the final value is less than 8. For some reason this value in cell B2 is testing as if it's less than 8 in the macro.

I extend it out to like 50 digits and it still looks like 8.000000 etc. I assign each value as a Double variable and take the difference and it's exactly 0. Excel < operator seems to think it is not less than 8. But VBA thinks that it is less than 8.

The value in this field for this macro has been equal to '8' at least a thousand times since I created this routine, and I've never had this problem before...the 8 in cell B1 for example doesn't test true for < 8 in VBA...I don't know what else to look for or check to see why it's thinking that B2 is < 8.

I attached a picture I'm not sure if it will work though. Working in Excel 2010 by the way. Thanks in advance.

 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Is the code definitely lookinh at the right sheet?
 
Upvote 0
What if you test
Code:
Round(cells(1, 2).value, 7) < 8
 
Upvote 0

Forum statistics

Threads
1,214,788
Messages
6,121,575
Members
449,039
Latest member
Arbind kumar

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