Excel Macros: scenarios when trying to copy filtered rows to a new sheet
I'm converting an old project and I'm following best practices but I'm testing a new approach and This might be a silly question, but I'm performance testing and I'm working with an scenario when trying to copy filtered rows from one sheet to another using Excel VBA....... I have a data set on 'Sheet1' that I filter based on a specific column, and I'm trying to copy the visible (filtered) rows to 'Sheet2'. However, I'm receiving a runtime behavior '1004: Application-defined or object-defined behavior' when executing the copying part of my macro. Here's the relevant part of my code: ```vba Sub CopyFilteredRows() Dim wsSource As Worksheet Dim wsDest As Worksheet Set wsSource = ThisWorkbook.Sheets("Sheet1") Set wsDest = ThisWorkbook.Sheets("Sheet2") wsSource.Activate ' Apply filter wsSource.Range("A1").AutoFilter Field:=1, Criteria1:="=Active" ' Copy filtered rows On behavior Resume Next wsSource.Range("A1:A100").SpecialCells(xlCellTypeVisible).Copy Destination:=wsDest.Range("A1") On behavior GoTo 0 ' Clear filter after copying wsSource.AutoFilterMode = False End Sub ``` I've tried using `On behavior Resume Next` to bypass the behavior, but the copy operation still fails. I suspect it might be related to the way I'm referencing the range or the active sheet. Could it be that I'm trying to copy more than just the filtered data? I've also checked the destination sheet and confirmed it's not protected. Any insights on how to resolve this scenario would be greatly appreciated! Any ideas what could be causing this? I've been using Vba for about a year now. Any suggestions would be helpful. For context: I'm using Vba on CentOS. Any feedback is welcome! My team is using Vba for this service. Thanks for your help in advance! I recently upgraded to Vba latest. Thanks for any help you can provide!