+ Reply to Thread
Results 1 to 4 of 4

VBA Select all data in a filtered range

  1. #1
    Registered User
    Join Date
    03-27-2020
    Location
    London
    MS-Off Ver
    Office 365 Business
    Posts
    6

    VBA Select all data in a filtered range

    Hi,

    Excuse me if I'm asking an idiotic question, but I've just started learning how to use macros and vba.

    I have a working macro, however if used in a filtered data it will only select the visible data. I want it to disregard any filters and select everything within certain range. Searching for a solution I find many people asking the opposite - how to select only visible cells, but can't find anything on my query.

    Normally, it starts like this - I want to copy everything between F:J, regardless of applied filters:

    Sheets("X").Select
    Columns("F:J").Select
    Selection.Copy

    In the end I also have an autofill which I would want to apply to all cells, including those filtered out - it's meant to autofill a formula:

    Range("G2:J2").Select
    Selection.AutoFill Destination:=Range("G2:J" & Range("F" & Rows.Count).End(xlUp).Row), Type:=xlFillDefault
    Range("G2").Select

    Thanks in advance.

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,301

    Re: VBA Select all data in a filtered range

    When you work with a block of cells that has been filtered, only the visible cells will be modified. If you want to work without removing the filter, you need code like this

    Please Login or Register  to view this content.
    Personally, I find it is much easier to just remove the filter or check for filters and not run the code.
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Registered User
    Join Date
    03-27-2020
    Location
    London
    MS-Off Ver
    Office 365 Business
    Posts
    6

    Re: VBA Select all data in a filtered range

    I decided to go with your advice and remove the filters first with this:

    On Error Resume Next
    ActiveSheet.ShowAllData

  4. #4
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,301

    Re: VBA Select all data in a filtered range

    Smart move

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Copy filtered data into filtered range in a separate sheet
    By vikas.trades25 in forum Excel General
    Replies: 1
    Last Post: 02-07-2019, 04:04 AM
  2. Select visible row filtered data
    By Nipius in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-03-2017, 03:17 PM
  3. [SOLVED] Select filtered data
    By flashdisk in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 06-02-2013, 09:53 AM
  4. [SOLVED] select one cell in a filtered range
    By ahoe800 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-10-2013, 12:07 PM
  5. Input Box Auto Filtered as Text in a range for user to select periods
    By excelrcb3 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-13-2012, 04:56 PM
  6. select filtered data only
    By cmb80 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-08-2011, 05:46 AM
  7. Select data in filtered list
    By Stephen Rainey in forum Excel General
    Replies: 2
    Last Post: 07-28-2006, 07:40 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1