Curious number problem (or bad code)

mqarep

Board Regular
Joined
Mar 12, 2002
Messages
91
I have a curious problem (curious to me anyway).
The following code looks at a subtotal in cell BB33 and then selects the appropriate shipping cost.
An example of the problem is that shipping will not equal $20 until the subtotal is 100.51. Anything between 100 and 100.50, $15.00 is incorrectly selected.
What is going wrong here?

'Shipping Costs
If Not Intersect(Target, Range("A21:AW32")) Is Nothing Then
amount = ActiveSheet.Range("BB33")
Select Case amount
Case 0 To 50#
shipping = 10
Case 50.01 To 99.99
shipping = 15
Case 100# To 149.99
shipping = 20
Case 150# To 249.99
shipping = 25
Case 250# To 349.99
shipping = 35
Case 350# To 499.99
shipping = 50
Case Is > 499.99
shipping = 0.1 * ActiveSheet.Range("BB33")
End Select
ActiveSheet.Range("BB35") = shipping
End If
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
I can't replicate your issue. I just tested your code with 100.01, 100.1, and 100.25. All three returned 20 as desired...

Did you accidentally declare amount as an integer or something?
 
Upvote 0

Forum statistics

Threads
1,203,189
Messages
6,054,014
Members
444,696
Latest member
VASUCH

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