简体   繁体   中英

How to avoid "run-time error" if code seems to work but stops at the middle?

I have a worksheet where I had to loop through all the stocks for one year and output:

  • The ticker symbol
  • Yearly change (didn't get there yet).
  • The percentage change (didn't get there yet).
  • The total stock volume of the stock.

I did the first task but I got stuck with the total stock volume. The script gets the total volume for the first few tickers but doesn't run further.

the worksheet with unique tickers in "I" column and not complete Total Volume in "L" column

When I run my script I am getting Run-time error '6': Overflow. I changed my data type from Integer to Long and it didn't help.

I will appreciate any help or explanation of the problem. Thank you.

My script with highlighted, by debugger, line of the code

Long will support values up to 2147483647, and the value you have for AAB (cell L3) already comes dangerously close to that. You should probably consider using a data type that will allow for larger values. See VBA datatypes here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM