0

Any idea why this is giving me a run time error 6: Overflow?

Sheets("Raw data").Select
Dim lastrow2 As Integer
Dim lastcol2 As Integer

lastcol2 = Cells(1, Columns.Count).End(xlToLeft).Column
lastrow2 = Cells(Rows.Count, 1).End(xlUp).Row

Range(Cells(1, 1), Cells(lastrow2, lastcol2)).Name = "RawData"

I've used the exact same vbs code on a different sheet and it runs fine. All I've done is renamed the variables as lastrow2 and lastcol2. It's the lastrow2 line that's giving me problems I think.

  • 2
    Declare as Long not Integer and see if that fixed the problem. – QHarr Jul 30 '18 at 09:49
  • There is very few advantages using `Integer` type, use `Long` instead. – Vincent G Jul 30 '18 at 09:49
  • I have a similar problem with ``` m = WorksheetFunction.CountA(Sheets("FundedAmounts").Columns(1)) ``` and defining m as a Long instead of a Integer, fixed my problem. – GenDemo Oct 06 '20 at 04:07

0 Answers0