run time error '6' --- Overflow

magoobee

New Member
Joined
Nov 22, 2004
Messages
39
I do not really know VBA, but did put together some macros. They use to work but now I get this error

Run-time error '6':
Overflow

The following is the code. I get the error on the last line when I debug. Any idea what is wrong? Thanks

Code:
Sub ColorRate()
    Dim LastR As Integer, CurrRow As Integer
    Dim PercRange As Range, Thing
    Sheets("STOCKS").Activate               'Activate sheet
    Range("A3").Select                      'Select top of column
    Selection.End(xlDown).Select                  'Find bottom of column
    LastR = ActiveCell.Row                        'Get row number

EDIT: Fixed Code tags (Smitty)
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
You will get this error when Column A is totally blank. It's searching for data and runs all the way to the bottom.

Note also that LastR will only equal the first row with data if A1 is empty, or LastR will only equal the last row with data prior to a blank if A1 has something in it; i.e. if A1:A7 has data, A8 is blank, then A9:A20 contains more data, LastR will equal 7, not 20.
 
Upvote 0
Thanks for the help

Filling Column A worked. Thanks

Now my coloring does not work. Let me try and fix that before I ask for more help.

Life is tough when you do not know what your doing. :confused:
 
Upvote 0
Dim LastR as Long

Excel currently allows for 65,536 rows, soon to be ~1.1 million, so your Integer variable was being overrun.
 
Upvote 0

Forum statistics

Threads
1,214,983
Messages
6,122,591
Members
449,089
Latest member
Motoracer88

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