Take a very simple spreadsheet
Run the following code on it. It just copies the sheet to an array and then back again. It should not make any difference to the sheet.
Option Explicit
Sub Test()
Dim vArr As Variant
' Copy the contents of the sheet to a 2D variant array
vArr = Sheets("Sheet1").Cells(1, 1).CurrentRegion
' Copy the variant array back to the sheet
Sheets("Sheet1").Cells(1, 1).Resize(UBound(vArr, 1), UBound(vArr, 2)) = vArr
' There should be no difference to the sheet
End Sub
All works fine. Now filter the sheet and exclude row 2 (or indeed any other row)
Run the code again and you get a mess:
Is this a bug or is there some deeper philosophy at work here? Is there a way round this, short of clearing the filter.
UPDATE I would also note that there is a difference between hidden rows and filtered rows. If you hide a row then the code works fine. It seems to be only to do with filtering.


