Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6327965
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:22:26+00:00 2026-05-24T17:22:26+00:00

Current i have an excel with roughly 200000+ records and i need to filter

  • 0

Current i have an excel with roughly 200000+ records and i need to filter data based on a column. The column has around 5 values and i need to filter out 2 values in one sheet and the rest 3 to remain in the same sheet.

Now instead of using cell by cell comparison to check whether the value of the cell falls in any of the above 2 values and then cut paste the row into another sheet. This wouldn’t work with 200k+ records and simply hangs,.

Instead am planning to take the auto filter method. I tried using the ‘Record macro’ feature, but the problem is that it gives me some error like

“Excel cannot create or use the data range reference because its too complex.Try one of the following
Use data that can be selected in rectangle
Use data from the same sheet”

Moreover how to copy paste only the filtered values to another sheet? If I try to copy paste directly or special paste as ‘values’ then also even the hidden rows get copy pasted.

Below is the macro code i have been tampering around with

    Sub Macro34()
    '
    ' Macro34 Macro
    '

    '
        Rows("1:1").Select
        Selection.AutoFilter
        ActiveSheet.Range("$A$1:$T$81335").AutoFilter Field:=6, Criteria1:="=242", _
            Operator:=xlOr, Criteria2:="=244"
        Cells.Select
        Selection.Copy
        ActiveWindow.SmallScroll Down:=21
        Sheets("Sheet2").Select
        ActiveWindow.SmallScroll Down:=-18
        Range("A1").Select
        ActiveSheet.Paste
        Application.CutCopyMode = False
        Selection.ClearContents
        Range("A1").Select
        Sheets("Sheet1").Select
        Selection.Copy
        Sheets("Sheet2").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        Sheets("Sheet2").Select
        ActiveWindow.SmallScroll Down:=93
        Sheets("Sheet1").Select
        ActiveWindow.SmallScroll Down:=-9
        ActiveWindow.ScrollRow = 1
        Rows("1:1").Select
        Application.CutCopyMode = False
        Selection.AutoFilter
    End Sub

There might be some junk lines of code above as its generated using the ‘record macro’ feature.

Could someone please help me. The problem is the amount of data present in excel. Cant excel not handle this much data in VBA? Am using Excel 2007

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T17:22:27+00:00Added an answer on May 24, 2026 at 5:22 pm

    Here’s your code cleaned up:

    Sub Macro34()
    
        ' Turn off autofiltering
        If ActiveSheet.AutoFilterMode Then ActiveSheet.AutoFilterMode = False
    
        ' Turn it back on
        Rows(1).AutoFilter
    
        ' Set the autofiltering conditions
        Rows(1).AutoFilter Field:=6, _
            Criteria1:="=242", _
            Operator:=xlOr, _
            Criteria2:="=244"
    
        ' Copy only the relevant range
        Range("A1", _
              Cells(65536, Cells(1, 256).End(xlToLeft).Column).End(xlUp)).SpecialCells(xlCellTypeVisible).Copy
    
        ' Paste the data into Sheet2 (assuming that it exists)
        Sheets("Sheet2").Range("A1").PasteSpecial xlPasteValuesAndNumberFormats
        Application.CutCopyMode = False
    
    End Sub
    

    The key is that SpecialCells part.

    Now, as much as I love a good autofilter copy/paste, when you’re dealing with that much data, you might want to look into using ADO, which would allow you to query your Excel worksheet using SQL.

    A good overview of ADO in VBA is provided here: http://www.xtremevbtalk.com/showthread.php?t=217783.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My current scenario is that I have 20 Excel files that need to be
I have the current basic structure for each domain object that I need to
At my current job we have a CMS system that is .NET/SQL Server based.
I have an EXCEL sheet.it has various form-fields that are named as smrBgm133GallonsGross/ smrBgm167GallonsGross
currently I have a web which loads excel spreadsheet data into SQL database. When
I have the need to pass the current model of the view, from the
I have a large collection of data in an excel file (and csv files).
I have an Excel file that has a bunch of VBA and macro code
I want to get values from other sheets. I have some values in Excel
I have Microsoft Excel 2000 on my pc. I want to show the current

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.