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

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.

xapie128

Board Regular
Joined
Aug 26, 2006
Messages
82
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.
 

magoobee

New Member
Joined
Nov 22, 2004
Messages
39
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:
 

just_jon

Legend
Joined
Sep 3, 2002
Messages
10,473
Dim LastR as Long

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

Forum statistics

Threads
1,136,263
Messages
5,674,710
Members
419,521
Latest member
Jasonnie

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
Top