Copying filtered excel data

Copying and pasting are probably one of the most used actions in an Excel spreadsheet.

But when it comes to filtered data, copy-pasting data is not always smooth.

Ever tried pasting something to a table that has been filtered? It’s not as easy as it sounds.

In this tutorial, I will show you how to copy data from a filtered dataset and how to paste in a filtered column while skipping the hidden cells.

Suppose you have the below dataset:

Dataset to copy and paste in filtered rows

Given the above table, say you want to copy all the rows of employees from the IT department only.

For this, you can apply a filter to your table as follows:

  1. Select the entire table.
  2. From the Data tab, select the ‘Filter’ button under the ‘Sort & Filter’ group.
  3. You will notice small arrows on every cell of the header row. These are meant to help you filter your cells. You can click on any arrow to choose a filter for the corresponding column.
  4. In this example, we want to filter out only the rows that contain the Department “IT”. So, select the arrow next to the Department header and uncheck the boxes next to all the departments, except “IT”. You can simply uncheck “Select All” to quickly uncheck everything and then just select “IT”.
  5. Click OK. You will now see only the rows with Department “IT”.

All the rows with IT are filtered

Now, copying from a filtered table is quite straightforward. When you copy from a filtered column or table, Excel automatically copies only the visible rows.

So, all you need to do is:

  1. Select the visible rows that you want to copy.
  2. Press CTRL+C or right-click->Copy to copy these selected rows.
  3. Select the first cell where you want to paste the copied cells.
  4. Press CTRL+V or right-click->Paste to paste the cells.

This should cause only the visible rows from the filtered table to get pasted.

Occasionally you might come across issues in copying the visible rows, especially when working with Subtotals or similar features.

In such cases, copying only the visible rows is quite easy too. Here’s what you need to do:

  1. Select the visible rows that you want to copy.
  2. Press ALT+; (ALT key and semicolon key together). If you’re on a Mac, press Cmd+Shift+Z. This shortcut lets you select only the visible rows, while skipping the hidden cells.
  3. Press CTRL+C or right-click->Copy to copy these selected rows.
  4. Select the first cell where you want to paste the copied cells.
  5. Press CTRL+V or right-click->Paste to paste the cells.

So you see copying from filtered columns is quite straightforward.

But you can’t say the same when it comes to pasting to a filtered column.

Pasting a Single Cell Value to All the Visible Rows of a Filtered Column

When it comes to pasting to a filtered column, there may be two cases:

  • You might want to paste a single value to all the visible cells of the filtered column.
  • You might want to paste a set of values to visible cells of the filtered column.

For the first case, pasting into a filtered column is quite easy.

Let’s say we want to replace all the cells that have Department = “IT” with the full form: “Information Technology”.

For this, you can type the word “Information Technology” in any blank cell, copy it, and paste it to the visible cells of the filtered “Department” Column. Here’s a step-by-step on how to do this:

  1. Select a blank cell and type the words “Information Technology”.
  2. Copy it by press CTRL+C or Right click->Copy.
  3. Select all the visible cells in the column with the “Department” header.
  4. Paste the copied value by pressing CTRL+V or Right click->Paste.

You will find the value “Information Technology” pasted to only the visible cells of the column “Department”.

To verify this, remove the filter by selecting the Data->Filter. Notice that all the other cells of the “Department” column remain unchanged.

Copy and Paste Information Technology in all filtered rows

Two Ways to Paste a Set of Values to Visible Rows of a Filtered Column

Now let’s see what happens when you want to paste a set of values to the visible cells of a filtered column. Say you want to paste a list of salaries for only the rows containing Department=”Information Technology”.

If you try copying these cells and pasting them to the filtered Salary column, you will probably get an error message like “The command cannot be used on multiple selections”.

The command cannot be used on multiple selections prompt

This is because you cannot paste to cells in a range that contains hidden rows or columns. It’s one of Excel’s limitations. There’s no way around that, but there are some tricks that you can use to get this done.

Here are two tricks that you can use to paste a set of values to a filtered column, skipping the hidden cells.

Pasting a Set of Values to Visible Rows of a Filtered Column – Using a Formula

In this method, we use a formula to simply copy the value of the cell to the destination cell.

For the above example (where you want to copy a set of salary values to only the rows of with Department= “Information Technology”), here are the steps you need to follow:

  1. Press the equal sign (‘=’) in the first cell of the column you want to paste to (G3).
  2. Now select the first cell from the list you want to copy (H3 in our example).
  3. This will just create a reference to the cell. You should see the formula: =H3 in cell G3.Enter the first cell reference
  4. Copy this formula down by dragging down the fill handle (at the bottom right corner of cell G3). This should paste the formula only to the visible cells of column G.
  5. To verify this, remove the filter by selecting Data->Filters. Here’s an image of column G without filters after the copy-paste operation. To make it clearer for you to see, I’ve highlighted the copied cells in light green.Formula result is visible in earlier filtered rows only
  6. Now what you copied were just references to the original cells. So if you try to remove the original cells once you’re done copy-pasting, the copied values will disappear from column G too.
  7. To avoid this, you need to paste these formula results as values. This is quite easy. While you’re in the unfiltered mode, copy all the cells of column G, right-click and select ‘Paste Values’ from the popup menu.Paste as Values
  8. That’s it, you can now go ahead and delete the original values.

Pasting a Set of Values to Visible Rows of a Filtered Column – Using VBScript

This is a fairly easier and quicker method. All you need to do is copy the VBScript given below into your developer window and run it.

Sub paste_to_filtered_col()
Dim s As Range
Dim visible_source_cells As Range
Dim destination_cells As Range
Dim source_cell As Range
Dim dest_cell As Range
Set s = Application.Selection
s.SpecialCells(xlCellTypeVisible).Select
Set visible_source_cells = Application.Selection
Set destination_cells = Application.InputBox("Please select the destination cells:", Type:=8)
For Each source_cell In visible_source_cells
source_cell.Copy
For Each dest_cell In destination_cells
If dest_cell.EntireRow.RowHeight <> 0 Then
dest_cell.PasteSpecial
Set destination_cells = dest_cell.Offset(1).Resize(destination_cells.Rows.Count)
Exit For
End If
Next dest_cell
Next source_cell
End Sub

Follow these steps to use the above code:

  1. Select all the rows you need to filter (including the column headers).
  2. From the Developer Menu Ribbon, select Visual Basic.
  3. Once your VBA window opens, Click Insert->Module and paste the above code in the module window.

Your macro is now ready to run. To run the code:

  1. First, select the cells that you want to copy.
  2. Run the script by navigating to Developer->Macros-> paste_to_filtered_col
  3. The code will ask you to select your destination cells (where you want to paste the copied cells).
  4. Select the cells and click OK.Select the range

Your selected cells will now be copied and pasted to the destination cells. You can go ahead and delete the original cells if you want.

Pasted using Macros

You can also create a small shortcut (using the Quick Access Toolbar) to run your macro whenever you need it. Here’s how:

  1. Click the Customize Toolbar arrow, which you’ll find above Excel’s menu ribbon.
  2. Select ‘More Commands’ from the dropdown menu that appears.
  3. This will open the ‘Excel Options’ dialog box.
  4. Click on the drop-down list below ‘Choose Commands From’ and select ‘Macros’.
  5. Select the name of the macro you created. In our case, it’s ‘ThisWorkbook.paste_to_filtered_col’ Click on the ‘Add>>’ button.
  6. Click OK.

You’ll now get a Quick Access macro button to quickly run your macro with a single click.

Macro in Quick Access Toolbar

Whenever you need to copy and paste a set of cells to a filtered column, just select your source cells, click on this created button and then select the destination cells.

When you click OK, you should get your source cells copied into your selected destination cells.

So this is how you can copy and paste in a filtered column while skipping the hidden rows.

I hope you found this tutorial useful!

Other Excel tutorials you may like:

  • How to Delete Filtered Rows in Excel (with and without VBA)
  • How to Filter as You Type in Excel (With and Without VBA)
  • How to Unsort in Excel (Revert Back to Original Data)
  • How to Hide Rows based on Cell Value in Excel
  • How to Compare Two Cells in Excel?
  • How to Paste without Formatting in Excel (Shortcuts)
  • How to Clear Filter in Excel? Shortcut!
  • Copy and Paste shortcuts in Excel
  • How to Filter by Color in Excel?

See all How-To Articles

This tutorial demonstrates how to copy filtered (visible) data in Excel and Google Sheets.

copy filtered data 7

Copy Filtered Data

Say you have the following sales dataset and want to filter and copy only rows with Feb-21 in Column C (Month).

copy filtered data initial data

  1. First, turn on AutoFilter arrows to be able to filter data.
    Click anywhere in the data range, and in the Ribbon, go to Home > Sort & Filter > Filter.

copy filtered data 1

  1. Now, click on the AutoFilter icon in Column C heading, tick February (under 2021), and click OK.

copy filtered data 2

  1. As a result of previous steps, only rows with the month Feb-2021 are filtered. To copy only visible cells, select the data range you want to copy (B1:D10), and in the Ribbon, go to Home > Find & Select > Go To Special…

copy filtered data 3

  1. In the Go To Special dialog box, check Visible cells only and click OK.

copy filtered data 4

    1. Now only visible cells (filtered data) are selected. Right-click anywhere in the selected area, and click Copy (or use the keyboard shortcut CTRL + C).

copy filtered data 5

  1. Right-click the cell where you want to paste the data, and choose Paste (or use the keyboard shortcut CTRL + V).

copy filtered data 6

This copies only the filtered data (Feb-21).

copy filtered data final data

Copy Filtered Data in Google Sheets

Say you have the following dataset and want to filter and copy only rows with the word Wireless in Column A (Product).

custom autofilter new 8

  1. First, turn on filter arrows. Click anywhere in the data range, and in the Toolbar, click the Filter button.

custom autofilter new 2

  1. Now, click on the Filter icon in the Column A heading, click on Filter by condition, and choose Text contains.

custom autofilter new 3

  1. In the box enter the wanted text (in this example Wireless) and press OK.

custom autofilter new 5

As a result, only rows with the word Wireless are visible.

custom autofilter new 6

    1. To copy only visible cells, select the data range you want to copy (A1:B6), right-click it, and choose Copy (or use the CTRL + C shortcut).

copy filtered data visible cells new 5

  1. Select the cell where you want to paste the data, then right-click and click Paste.

copy filtered data visible cells new 6

This copies over only filtered data.

copy filtered data visible cells new 4


Asked by: Pedro Ullrich

Score: 4.9/5
(70 votes)

Follow these steps:

  1. Select the cells that you want to copy For more information, see Select cells, ranges, rows, or columns on a worksheet. …
  2. Click Home > Find & Select, and pick Go To Special.
  3. Click Visible cells only > OK.
  4. Click Copy (or press Ctrl+C).

What is the shortcut to Copy filtered data in Excel?

To copy data into the same rows in a filtered list:

  1. Select the cells that you want to copy.
  2. Press Ctrl and select the cells where you want to paste (in the same rows)
  3. To select only the visible cells in the selection, press Alt + ; (the semi-colon)
  4. To copy to the right, press Ctrl + R.

How do I paste excluding hidden cells?

This shortcut lets you select only the visible rows, while skipping the hidden cells. Press CTRL+C or right-click->Copy to copy these selected rows. Select the first cell where you want to paste the copied cells. Press CTRL+V or right-click->Paste to paste the cells.

How do I extract data from a filter in Excel?

Select a cell in the database. On the Excel Ribbon’s Data tab, click Advanced. In the Advanced Filter dialog box, choose ‘Copy to another location’. For the List range, select the column(s) from which you want to extract the unique values.

Can you copy filter list in Excel?

By default, Excel copies hidden or filtered cells in addition to visible cells. … Click Visible cells only > OK. Click Copy (or press Ctrl+C). Select the upper-left cell of the paste area and click Paste (or press Ctrl+V).

36 related questions found

How do you copy all filters in Excel?

Copying the Results of Filtering

  1. Select the area you want to filter.
  2. Display the Data tab of the ribbon.
  3. Click the Advanced tool, in the Sort & Filter group. …
  4. Set your filtering options as desired.
  5. Make sure the Copy to Another Location radio button is selected.
  6. Specify a copy destination in the Copy To field.

How do I paste into a filtered column?

If you want to pasting cells into a hidden or filtered cells, you need to select the visible blank cells firstly with Alt + ; shortcut, and then just press Ctrl + C keys to copy the selected cells, and then press Ctrl + V to paste your data into the selected visible cells.

How do I copy and paste a filtered list in Excel?

Press CTRL C to copy the selected visible cells to the Clipboard. Select a destination cell (can be on the same sheet, a different sheet, or on a new workbook). Paste the range by pressing CTRL V. Excel copies only the subtotaled rows.

How do I select filtered cells in Excel?

Here are the steps:

  1. Select the data set in which you want to select the visible cells.
  2. Go to the Home tab.
  3. In the Editing group, click on Find and Select.
  4. Click on Go To Special.
  5. In the ‘Go To Special’ dialog box, select ‘Visible cells only’.
  6. Click OK.

How do I copy merged and filtered cells in Excel?

Copy & Paste Visible Cells

  1. Select the entire range you want to copy.
  2. Press Alt+; to select the visible cells only. …
  3. Copy the range – Press Ctrl+C or Right-click>Copy.
  4. Select the cell or range that you want to paste to.
  5. Paste the range – Press Ctrl+V or Right-click>Paste.

How do you drag formulas into filtered cells?

For those who don’t like to drag down with the mouse:

  1. Copy the cell with the formula.
  2. Navigate to the bottom of your table.
  3. Select the bottom-most cell in the column where you want the formulas to be.
  4. press <CTRL><SHIFT><Arrow-up>
  5. Press paste.

What will you see if you copy a filtered list to another worksheet?

Press Ctrl + V to paste the data into the new worksheet. The data that is pasted will only be the visible data from the filter. The rows that were hidden by the filter will not be pasted.

How do you copy to clipboard in Excel?

Select the first item that you want to copy, and press CTRL+C. Continue copying items from the same or other files until you have collected all of the items that you want. The Office Clipboard can hold up to 24 items.

How do you fill a series in filtered cells in Excel?

Please do as follows.

  1. Select the range with all filtered out cells you want to fill with same content, and then press the F5 key.
  2. In the popping up Go To dialog box, click the Special button. …
  3. In the Go To Special dialog box, select the Visible cells only option, and then click the OK button.

How do I convert a formula to a filtered list?

Convert adjacent formula cells to values

  1. Select all cells you want to convert.
  2. Copy them, either by clicking on the Copy button on the Home ribbon or pressing Ctrl + C on the keyboard.
  3. Paste them using “Paste Special”. Instead of pressing Ctrl + V, press Ctrl + Alt + V on the keyboard.
  4. Select “Values”.
  5. Click on OK.

How do I change only filtered cells in Excel?

Select cells you will replace in the filter range, and press Alt + ; keys simultaneously to select only visible cells. 2. Type the value that you will replace with, and press the Ctrl + Enter keys at the same time. Then you will see all selected cells in filtered range are replaced by the typed values at once.

How do I copy a list of data in Excel?

To paste a bullet list from Word into a single cell in Excel, copy the bullet list in Word, toggle to Excel, select the desired cell, press the F2 key to invoke edit mode, and then paste, as suggested by the screenshots below. The bullet list will paste into a single Excel cell.

How do I filter data from one worksheet to another in Excel dynamically?

Solution for all versions of MS Excel

  1. Select range A1:O82 and press Ctrl+F3 > New > Name. …
  2. Select range A1:O82 and press Ctrl+T. …
  3. Save the file (assume on the Desktop for now)
  4. Open a blank worksheet and go to Data > From Other Sources > From Microsoft Query.
  5. Select Excel files and click on OK.

How do I show filtered data in another sheet?

2 Answers

  1. Select Range- go to Data- select From Range/Table- Enter Power Query Editor:
  2. Filter Gender Column- Close and Load to New WorkSheet:

How do I filter data from one sheet to another?

How to Filter Data from One Sheet Based on Another Sheet in Excel…

  1. Sheet1:
  2. Sheet2:
  3. Step 1: In tool bar, click on Data->Advanced. …
  4. Step 2: In Advanced Filter window, keep default selected option ‘Filter the list, in-place’, in List range, enter the range you want to do filter, in this case enter $A$1:$A$7.

How do I copy an advanced filter to another sheet?

On the Data tab, in the Sort & Filter group, click Advanced. To filter the list range by copying rows that match your criteria to another area of the worksheet, click Copy to another location, click in the Copy to box, and then click the upper-left corner of the area where you want to paste the rows.

How do you copy a formula down thousands of cells?

On the keyboard, press Ctrl + D, to fill the formula down through the selected cells.

How do you copy formulas to thousands of cells?

You can always use the good ole’ copy and paste method.

  1. Set up your formula in the top cell.
  2. Either press Control + C or click the “Copy” button on the “Home” ribbon.
  3. Select all the cells to which you wish to copy the formula. …
  4. Either press Control + V or click the “Paste” button on the “Home” ribbon.

Why Excel Cannot copy merged cells?

Copy and paste a range of cells that matches the size of the merged cell. Cut or delete a row or column that includes a merged cell. Clear the contents of a row or column that includes a merged cell. Apply a filter to a column containing a merged cell, and then try to delete the merged cell.

totn Excel


This Excel tutorial explains how to copy filtered data to a new worksheet in Excel 2003 and older versions (with screenshots and step-by-step instructions).

Question: In Excel 2003/XP/2000/97, I’ve filtered my data in Excel and I want to copy the filtered data to another worksheet. How do I do this?

Answer: In newer versions of Excel, the copy of filtered data does not copy the hidden rows. Because of this, we will provide a few scenarios on how to copy filtered data.

Solution #1 — Copy only visible filtered data

Our first solution demonstrates how to copy only the visible filtered data to a new worksheet.

To do this, open your Excel spreadsheet and select the filtered data. Press Ctrl+C to copy the data.

Microsoft Excel

Next, select the worksheet where you’d like to paste the data. Press Ctrl+V to paste the data into the new worksheet.

Microsoft Excel

The data that is pasted will only be the visible data from the filter. The rows that were hidden by the filter will not be pasted.

Solution #2 — Copy visible and hidden filtered data

Unfortunately, you can not copy and paste any of the hidden filtered data with the standard copy and paste functionality inherent in Excel. If you wish to copy all of the data, you’ll have to remove the filter before copying.

To do this, select a cell in one of the filtered rows. Under the Data menu, select Filter > Show All.

Microsoft Excel

Now all of the rows should be visible. Select all of the data and press Ctrl+C.

Microsoft Excel

Next, select the worksheet where you’d like to paste the data. Press Ctrl+V to paste the data into the new worksheet.

Microsoft Excel

Now all of the rows should appear in the pasted data. You can now re-apply your filters.

I have two sheets. One has the complete data and the other is based on the filter applied on the first sheet.

Name of the data sheet : Data
Name of the filtered Sheet : Hoky

I am just taking a small portion of data for simplicity. MY objective is to copy the data from Data Sheet, based on the filter. I have a macro which somehow works but its hard-coded and is a recorded macro.

My problems are:

  1. The number of rows is different everytime. (manual effort)
  2. Columns are not in order.

enter image description here
enter image description here

Sub TESTTHIS()
'
' TESTTHIS Macro
'
'FILTER
Range("F2").Select
Selection.AutoFilter
ActiveSheet.Range("$B$2:$F$12").AutoFilter Field:=5, Criteria1:="hockey"

'Data Selection and Copy
Range("C3").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Sheets("Hockey").Select
Range("E3").Select
ActiveSheet.Paste

Sheets("Data").Select
Range("D3").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Hockey").Select
Range("D3").Select
ActiveSheet.Paste

Sheets("Data").Select
Range("E3").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Hockey").Select
Range("C3").Select
ActiveSheet.Paste

End Sub

ashleedawg's user avatar

ashleedawg

20k8 gold badges73 silver badges104 bronze badges

asked Aug 24, 2016 at 11:21

Ananya Pandey's user avatar

Best way of doing it

Below code is to copy the visible data in DBExtract sheet, and paste it into duplicateRecords sheet, with only filtered values. Range selected by me is the maximum range that can be occupied by my data. You can change it as per your need.

  Sub selectVisibleRange()

    Dim DbExtract, DuplicateRecords As Worksheet
    Set DbExtract = ThisWorkbook.Sheets("Export Worksheet")
    Set DuplicateRecords = ThisWorkbook.Sheets("DuplicateRecords")

    DbExtract.Range("A1:BF9999").SpecialCells(xlCellTypeVisible).Copy
    DuplicateRecords.Cells(1, 1).PasteSpecial


    End Sub

answered Aug 22, 2017 at 1:46

Arpan Saini's user avatar

Arpan SainiArpan Saini

4,3541 gold badge38 silver badges50 bronze badges

1

I suggest you do it a different way.

In the following code I set as a Range the column with the sports name F and loop through each cell of it, check if it is «hockey» and if yes I insert the values in the other sheet one by one, by using Offset.

I do not think it is very complicated and even if you are just learning VBA, you should probably be able to understand every step. Please let me know if you need some clarification

Sub TestThat()

'Declare the variables
Dim DataSh As Worksheet
Dim HokySh As Worksheet
Dim SportsRange As Range
Dim rCell As Range
Dim i As Long

'Set the variables
Set DataSh = ThisWorkbook.Sheets("Data")
Set HokySh = ThisWorkbook.Sheets("Hoky")

Set SportsRange = DataSh.Range(DataSh.Cells(3, 6), DataSh.Cells(Rows.Count, 6).End(xlUp))
    'I went from the cell row3/column6 (or F3) and go down until the last non empty cell

    i = 2

    For Each rCell In SportsRange 'loop through each cell in the range

        If rCell = "hockey" Then 'check if the cell is equal to "hockey"

            i = i + 1                                'Row number (+1 everytime I found another "hockey")
            HokySh.Cells(i, 2) = i - 2               'S No.
            HokySh.Cells(i, 3) = rCell.Offset(0, -1) 'School
            HokySh.Cells(i, 4) = rCell.Offset(0, -2) 'Background
            HokySh.Cells(i, 5) = rCell.Offset(0, -3) 'Age

        End If

    Next rCell

End Sub

answered Aug 24, 2016 at 14:30

Rémi's user avatar

RémiRémi

3723 silver badges8 bronze badges

2

When i need to copy data from filtered table i use range.SpecialCells(xlCellTypeVisible).copy. Where the range is range of all data (without a filter).

Example:

Sub copy()
     'source worksheet
     dim ws as Worksheet
     set ws = Application.Worksheets("Data")' set you source worksheet here
     dim data_end_row_number as Integer
     data_end_row_number = ws.Range("B3").End(XlDown).Row.Number
    'enable filter
    ws.Range("B2:F2").AutoFilter Field:=2, Criteria1:="hockey", VisibleDropDown:=True
    ws.Range("B3:F" & data_end_row_number).SpecialCells(xlCellTypeVisible).Copy
    Application.Worksheets("Hoky").Range("B3").Paste
    'You have to add headers to Hoky worksheet
end sub

answered Aug 24, 2016 at 11:34

3

it needs to be .Row.count not Row.Number?

That’s what I used and it works fine
Sub TransfersToCleared()
Dim ws As Worksheet
Dim LastRow As Long
Set ws = Application.Worksheets(«Export (2)») ‘Data Source
LastRow = Range(«A» & Rows.Count).End(xlUp).Row
ws.Range(«A2:AB» & LastRow).SpecialCells(xlCellTypeVisible).Copy

answered Oct 6, 2020 at 18:09

Chunsah's user avatar

Понравилась статья? Поделить с друзьями:
  • Copying and pasting in excel
  • Copying a document in word
  • Copyfromrecordset in excel vba
  • Copy worksheets in excel vba
  • Copy worksheet with excel vba