Selection too large" is the error message if you do it manually. In code there is no warning the next action merely applies to all cells rather than just the blank ones.
Ok rant over, now how do I best fix my code? I regularly use it for large blocks of cells (lots of rows x several columns). As the code is often built into a larger routine I simply would not spot the issue so I want to avoid it.
This debugs at the red bit with the error "Run time error '6' overflow
I added the Round bit to see if that was the issue - no joy
In my test
r.rows.count=47,620
r.columns.count=1
It's late so I will look again tomorrow afternoon/evening. Thanks for any pointers.
Gavin
OK so fair enough but to say:However, when you use a VBA macro to make the same or a similar selection, no error message is raised and no error code is generated that can be captured through an error handler....
To work around this behavior, you may want to create a looping structure in your VBA macro that handles less than the maximum 8,192 cells.....
seems a bit rich - no error your code just messes up your data!!!This behavior is by design.
Ok rant over, now how do I best fix my code? I regularly use it for large blocks of cells (lots of rows x several columns). As the code is often built into a larger routine I simply would not spot the issue so I want to avoid it.
Code:
Sub FillBlanksFromAbove()
Dim r As Range, r2 As Range
Dim i As Integer
' Get around Excel limitation: [URL unfurl="true"]http://support.microsoft.com/default.aspx?scid=kb;en-us;832293[/URL]
Set r = Selection
[red]For i = 1 To r.Rows.Count Step Round((8192 / r.Columns.Count), 0)[/red]
Set r2 = Range(r.Cells(i, 1), r.Cells(Application.WorksheetFunction.Min(r.Rows.Count, 8192 / r.Columns.Count)))
r2.SpecialCells(xlCellTypeBlanks).FormulaR1C1 = "=R[-1]C"
r2.Value = r.Value
Next i
End Sub
I added the Round bit to see if that was the issue - no joy
In my test
r.rows.count=47,620
r.columns.count=1
It's late so I will look again tomorrow afternoon/evening. Thanks for any pointers.
Gavin