clear filter during importing

22newbie

New Member
Joined
Jun 11, 2022
Messages
13
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
I have a code to import closed workbook sheets into a Master sheet. However, some sheets have filters applied to a column or two. What code do I add to my current code to clear the filter of the closed worksheet when importing to Master sheet.

I tried adding with
VBA Code:
src.WB.ActiveSheet.ShowAllData
and it did not work.

Here's part of my code
Code:
    Const strPath As String = "C:\Users\TEST\Desktop\New folder\"
    ChDir strPath
    strExtension = Dir(strPath & "*.xlsx")
    i = 1
    Do While strExtension <> ""
        Set srcWB = Workbooks.Open(strPath & strExtension)
        With srcWB.Sheets(srcWB.Sheets.Count)
            LastRow = .Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
            If i = 1 Then
                .Range("A1").CurrentRegion.Copy desWS.Cells(desWS.Rows.Count, "A").End(xlUp).Offset(1, 0)
                numcol = .Range("A1").CurrentRegion.Columns.Count
            Else
                Set rng = .Range("A1").CurrentRegion
                Set rng = rng.Offset(1, 0)
                Set rng = rng.Resize(rng.Rows.Count - 1)
                rng.Copy desWS.Cells(desWS.Rows.Count, "A").End(xlUp).Offset(1, 0)
            End If
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.

Forum statistics

Threads
1,214,583
Messages
6,120,378
Members
448,955
Latest member
BatCoder

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