Hello,
My code worked yesterday. Now it gives me an error for 'Overflow'
This is my code snippet. The last line results in the overflow:
lastrow evaluates to 6534, as a long. rngSize in my example is b8:dp8 but can extend to row32 at times. When i hover my cursor over each part of that last statement it gives me a context tip which is correct (such as showing "range(rngSize.address)." as b8:dp8)![]()
Application.ScreenUpdating = False Sheets("MySheet").Unprotect Password:="**redacted**" Dim rngSize As Range Dim x As Variant Dim LastRow As Long 'On Error Resume Next x = Application.WorksheetFunction.CountA(Range("b8:b32")) If Not Range("r33").Value = 0 Then Range("B8:dp8").Offset(x, 0).Value = Range("b33:dp33").Value x = x + 1 End If Set rngSize = Range("b8:dp8").Resize(x) LastRow = Worksheets("admin").Range("c3").Value Range("DL8:Dl33").Value = Sheets("admin").Range("d4").Value Range("Do8:Do33").Value = Sheets("admin").Range("c5").Value Worksheets("admin").Range("c4").Value = Worksheets("admin").Range("c4").Value + 1 Worksheets("transactions").Range("B" & LastRow, "dp" & LastRow).Resize(rngSize.Rows.Count).Value = Range(rngSize.Address).Value
As previously stated, this code worked yesterday, and i can't understand why it wouldn't today. As a note, the value of lastrow increases each time this code is run, the value being stored in a cell on the admin page. yesterday it probably ran from 6300 down to 6534 where it is at now.
Help is appreciated, i'm a learner so you appreciate not just the answer but how I would get there for myself in future (though a straight answer isn't a bad thing by any means :P )
TIA
Bookmarks