VBA Overflow Run-Time Error

Exceller12

New Member
Joined
Jan 18, 2012
Messages
8
Hello Everybody,

I am receiving a run-time error for overflow when I run a macro that I have created. I have input cells for numbers that need to accept up to a trillion. However, when I enter 1,000,000,000,000, it will throw an overflow error. There are several places that I use a similar line of code, but the Debug takes me to the below line of code first.

If Worksheets(1).Cells(lRow, 41).value <> 0 Then

If there are any suggestions, it would be greatly appreciated.


Thanks a trillion in advance.
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
trial...
Code:
If Worksheets(1).Cells(lRow, 41).value <> vbnullstring Then
or perhaps there is an error in the cell? HTH. Dave
ps. 1 trillion cells?
 
Upvote 0
Thank you both for the assistance. Just to clarify some things. lRow is data type long and it is used to loop through rows. If I enter 1 trillion, the error occurs.

I have attempted to use vbnullstring in my code and the error is still occurring. I also need to save the contents of the cells to a variable. Do you know of a way to save 1 trillion in a variable, such as:
Var = Worksheets(1).Cells(lRow, 41).value
 
Upvote 0
lrow is number of rows... there can't be a trillion rows. Use data type double or variant to hold large numbers. Dave
 
Upvote 0
Just to clarify. I am not looking for one trillion rows. For instance, my issue is if $1 trillion dollars is entered into a cell, then the error occurrs.
 
Upvote 0

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

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