.autofilter to certain column

Lukums

Board Regular
Joined
Nov 23, 2015
Messages
195
G'day guys.

Have the below code:

Code:
Set TB = ActiveWorkbookWorkbooks.Open "C:\Users\Luke\Desktop\LIVE\Best Shed Scheduler Flashing.xlsm"
Set OB = ActiveWorkbook
erow = OB.Sheets("Corner Flashing Machine Data").Cells(Rows.Count, "A").End(xlUp).Offset(1, 0).Row
TB.Activate
Sheets("Corner").Range("H:Y").EntireColumn.Hidden = False
 With Sheets("Corner").UsedRange
            .AutoFilter
            .AutoFilter Field:=23, Criteria1:="Corner"
            .AutoFilter Field:=25, Criteria1:="JOB SCHEDULED"
            .Offset(1).Resize(.Rows.Count - 1).SpecialCells(xlCellTypeVisible).Copy OB.Sheets("Corner Flashing Machine Data").Cells(erow, 1)
            .AutoFilter
    End With
Sheets("Corner").Range("I:U").EntireColumn.Hidden = True
Sheets("Corner").Range("V:Y").EntireColumn.Hidden = False


OB.Save
OB.Close

Works fine as intended HOWEVER it's grabbing the entire row which has been fine up until recently. Now we wish to keep the same criteria but only copying from A:H and then pasting in the destination OB.Sheets("Corner Flashing Machine Data").Cells(erow, 1).

Any ideas?

Cheers!
 

Some videos you may like

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.

MARK858

MrExcel MVP
Joined
Nov 12, 2010
Messages
13,977
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
  2. Mobile
Untested....

Code:
    Set TB = ActiveWorkbook
    Workbooks.Open "C:\Users\Luke\Desktop\LIVE\Best Shed Scheduler Flashing.xlsm"
    Set OB = ActiveWorkbook
    erow = OB.Sheets("Corner Flashing Machine Data").Cells(Rows.Count, "A").End(xlUp).Offset(1, 0).Row
    TB.Activate
    Sheets("Corner").Range("H:Y").EntireColumn.Hidden = False
    With Sheets("Corner").UsedRange
        .AutoFilter
        .AutoFilter Field:=23, Criteria1:="Corner"
        .AutoFilter Field:=25, Criteria1:="JOB SCHEDULED"
        Intersect(.Offset(1).Resize(.Rows.Count - 1).SpecialCells(xlCellTypeVisible).EntireRow, Sheets("Corner").Columns("A:H")).Copy OB.Sheets("Corner Flashing Machine Data").Cells(erow, 1)
        .AutoFilter
    End With
    Sheets("Corner").Range("I:U").EntireColumn.Hidden = True
    Sheets("Corner").Range("V:Y").EntireColumn.Hidden = False


    OB.Save
    OB.Close
 

Lukums

Board Regular
Joined
Nov 23, 2015
Messages
195
Untested....

Code:
    Set TB = ActiveWorkbook
    Workbooks.Open "C:\Users\Luke\Desktop\LIVE\Best Shed Scheduler Flashing.xlsm"
    Set OB = ActiveWorkbook
    erow = OB.Sheets("Corner Flashing Machine Data").Cells(Rows.Count, "A").End(xlUp).Offset(1, 0).Row
    TB.Activate
    Sheets("Corner").Range("H:Y").EntireColumn.Hidden = False
    With Sheets("Corner").UsedRange
        .AutoFilter
        .AutoFilter Field:=23, Criteria1:="Corner"
        .AutoFilter Field:=25, Criteria1:="JOB SCHEDULED"
        Intersect(.Offset(1).Resize(.Rows.Count - 1).SpecialCells(xlCellTypeVisible).EntireRow, Sheets("Corner").Columns("A:H")).Copy OB.Sheets("Corner Flashing Machine Data").Cells(erow, 1)
        .AutoFilter
    End With
    Sheets("Corner").Range("I:U").EntireColumn.Hidden = True
    Sheets("Corner").Range("V:Y").EntireColumn.Hidden = False


    OB.Save
    OB.Close

Works as intended however 1 little thing quite weird actually there are some gaps in column H which meets the criteria as the data is sending to the page. Weird.

See below.
imagecolour.png
 

Watch MrExcel Video

Forum statistics

Threads
1,127,521
Messages
5,625,296
Members
416,087
Latest member
drth

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
Top