SamuelSeawall
New Member
- Joined
- Oct 21, 2021
- Messages
- 2
- Office Version
- 2019
- Platform
- Windows
Sub CopFilteredData2()
Dim rng As Range
Dim ws As Worksheet
Set ws = ThisWorkbook.Worksheets("Transhipment - October 2021")
If ws.AutoFilterMode = False Then
ws.ListObjects("Inventory").Range.AutoFilter Field:=11, Criteria1:="On Terminal"
End If
Set rng = ws.ListObjects("Inventory").Range
rng.SpecialCells(xlCellTypeVisible).Copy 'Only the visible cells and not all of them
ws.ListObjects("Inventory").AutoFilter.ShowAllData 'This is intended to reset the filters on the 'Inventory' table
Dim wb As Workbook, NewWS As Worksheet
Set wb = Application.Workbooks.Add
Set NewWS = wb.Sheets(1)
ActiveWorkbook.Sheets("Sheet1").ListObjects.Add(xlSrcRange, Range("$A$1:$N$1"), , xlYes).Name = _
"Table2"
NewWS.Paste
Sheets.Add After:=NewWS
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
ActiveSheet.ListObjects.Add(xlSrcRange, Range("$A:$A"), , xlYes).Name = _
"Table1"
Columns("A:A").Select
ActiveWorkbook.Names.Add Name:="T_S_auto", RefersToR1C1:= _
"=Table1[[#All],[Column1]]"
Dim K As Range
Set K = Range("K2").End(xlDown)
NewWS.Range("K2").FormulaR1C1 = "=IF([@[Match ]]>0,""LOADED"", ""ON TERMINAL"")"
NewWS.Range("L2").FormulaR1C1 = "=IFERROR(MATCH([@VIN],T_S_auto,0),0)"
NewWS.Range("N2").FormulaR1C1 = "=IFERROR(DAYS([@[Dep. date]],[@ETA]),0)"
'=IF([@[Match ]]>0,"LOADED", "ON TERMINAL")
'=IFERROR(MATCH([@VIN],Loaded,0),0)
End Sub
Dim rng As Range
Dim ws As Worksheet
Set ws = ThisWorkbook.Worksheets("Transhipment - October 2021")
If ws.AutoFilterMode = False Then
ws.ListObjects("Inventory").Range.AutoFilter Field:=11, Criteria1:="On Terminal"
End If
Set rng = ws.ListObjects("Inventory").Range
rng.SpecialCells(xlCellTypeVisible).Copy 'Only the visible cells and not all of them
ws.ListObjects("Inventory").AutoFilter.ShowAllData 'This is intended to reset the filters on the 'Inventory' table
Dim wb As Workbook, NewWS As Worksheet
Set wb = Application.Workbooks.Add
Set NewWS = wb.Sheets(1)
ActiveWorkbook.Sheets("Sheet1").ListObjects.Add(xlSrcRange, Range("$A$1:$N$1"), , xlYes).Name = _
"Table2"
NewWS.Paste
Sheets.Add After:=NewWS
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
ActiveSheet.ListObjects.Add(xlSrcRange, Range("$A:$A"), , xlYes).Name = _
"Table1"
Columns("A:A").Select
ActiveWorkbook.Names.Add Name:="T_S_auto", RefersToR1C1:= _
"=Table1[[#All],[Column1]]"
Dim K As Range
Set K = Range("K2").End(xlDown)
NewWS.Range("K2").FormulaR1C1 = "=IF([@[Match ]]>0,""LOADED"", ""ON TERMINAL"")"
NewWS.Range("L2").FormulaR1C1 = "=IFERROR(MATCH([@VIN],T_S_auto,0),0)"
NewWS.Range("N2").FormulaR1C1 = "=IFERROR(DAYS([@[Dep. date]],[@ETA]),0)"
'=IF([@[Match ]]>0,"LOADED", "ON TERMINAL")
'=IFERROR(MATCH([@VIN],Loaded,0),0)
End Sub