Specialcells limit

bengalfan

New Member
Joined
May 15, 2011
Messages
1
Hello,

I am working with Excel 2003, and I have been searching for how to fix an issue that has been coming up with an Excel sheet developed by someone else. The specific error I get when I run my selections is: runtime error 1004 excel cannot create or use the data range reference because it is too complex.

This is where the debug leads me within the code:

Code:
Function DR(Criteria As String, pos As Integer, IndexString As String)
    Sheets(IndexString).Select
    Selection.AutoFilter
    Selection.AutoFilter Field:=pos, Criteria1:=Criteria
    [COLOR="Red"]ActiveSheet.UsedRange.SpecialCells(xlCellTypeVisible).Areas(1).Columns(1).Cells(2, 1).Select[/COLOR]
    Range(Selection, Selection.End(xlToRight)).Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.EntireRow.Delete
    Range("A1").Select
    Selection.AutoFilter
End Function

I have been researching this issue and it seems like my query is exceeding the limit from within this section. I am not very versed with VBA (although I am now the owner of several books!). I'm not sure where specifically this error needs to be fixed? Any suggestions or help would be greatly appreciated.
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.

Forum statistics

Threads
1,224,600
Messages
6,179,833
Members
452,947
Latest member
Gerry_F

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top