changing cell type to integer

yky

Well-known Member
Joined
Jun 7, 2011
Messages
1,881
Office Version
  1. 2010
Platform
  1. Windows
I got an error message that says "Run-time error '6': Overflow".

The following line was highlighted.

I checked several variables type and value. cell.address was "$E$22", cell.value was 1500, and totalVoucherAmt was 31500. totalVoucherAmt was interget but cell.Value was Variant/Double. I checked several cells in column E and they all were of the type Variant/Double.

Could this discrepancy be the source of the error? If it is, how come the problem did not show up earlier, between E6 and E21?

How do I solve the problem? Thanks.

======================================
Set rng1 = Range("E6", [E330].End(xlUp))
rng1.NumberFormat = "0"
For Each cell In rng1
totalVoucherAmt = totalVoucherAmt + cell.Value <- highlighted
Next
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.

Forum statistics

Threads
1,224,618
Messages
6,179,917
Members
452,949
Latest member
beartooth91

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