VBA: How to copy data from a filtered list while preserving hidden rows?
I've tried everything I can think of but Hey everyone, I'm running into an issue that's driving me crazy. I'm trying to copy data from a filtered list in an Excel sheet using VBA, but I only want to copy the visible cells and ignore the hidden rows. I'm using the following code to copy data: ```vba Sub CopyFilteredData() Dim wsSource As Worksheet Dim wsDestination As Worksheet Dim rngSource As Range Dim rngVisible As Range Set wsSource = ThisWorkbook.Sheets("SourceSheet") Set wsDestination = ThisWorkbook.Sheets("DestinationSheet") Set rngSource = wsSource.Range("A1:B100").SpecialCells(xlCellTypeVisible) rngSource.Copy wsDestination.Range("A1") End Sub ``` However, I'm running into a question when there are merged cells in my source range. The `SpecialCells(xlCellTypeVisible)` method seems to throw an behavior stating "Application-defined or object-defined behavior" when it encounters the merged cells. I've tried unmerging the cells before copying, but that disrupts the layout of my data. What would be the best way to handle this situation? Is there a way to modify my code to effectively copy only the visible cells without running into issues with merged cells? Any suggestions or best practices would be greatly appreciated! I'm working on a web app that needs to handle this. How would you solve this? Thanks in advance!