Problem : microsoft office excel cannot create or use the data range reference because it is too complex

Problem : microsoft office excel cannot create or use the data range reference because it is too complex

Hi,

Please assist what or how can we troubleshoot this error, when I copy a range of cells this error popsup after pressing CTRL+C or even clicking the copy icon.

this only happen when the sheet has filter on (which i need to only copy the filtered data).

Thanks.

microsoft office excel cannot create or use the data range reference because it is too complex
use data that can be selected in one contiguous rectangle.
use data from the same sheet


Solution : microsoft office excel cannot create or use the data range reference because it is too complex

Looks like it’s the filter that’s to blame.
You need some code to loop through the rows to copy just the visible ones to another worksheet, then copy the range from there.
Something like this should do :
Sub CopyFiltered()
Dim wsFrom As Worksheet
Dim wsTo As Worksheet
Dim rngA As Range
Dim rngCell As Range

Dim lngNextRow As Long

Set wsFrom = Sheets(“Sheet1”)

Set wsTo = Sheets(“Sheet2”)
wsTo.UsedRange.Clear
lngNextRow = wsTo.Range(“a65536”).End(xlUp).Row

Set rngA = Intersect(wsFrom.[A:A], wsFrom.UsedRange)
For Each rngCell In rngA.SpecialCells(xlCellTypeVisible)
wsFrom.Rows(rngCell.Row).Copy
wsTo.Rows(lngNextRow).PasteSpecial Paste:=xlValues
lngNextRow = lngNextRow + 1
Next rngCell
End Sub