Hi all! I am trying to create a macro which produces an advanced filter based on data stored in other workbooks in the network. The problem I have is that if the other workbooks are not open, the macro does not work. I have no experience in VBA coding, only in macro recording, so even though I have tried to make some alterations to the code, I have been unsuccessful. Please find below the code as it is now, it does not work because the reference to the files must probably be done in some other way and I messed up changing it (I have changed the name of the links to fake ones for security reasons). Thank you very much for your help
Sub consolidation()
'
' consolidation Macro
'
'
Workbooks("http://bla.bla.com/Housing%20Specialists/Nouveaux%20tableaux/Tableau%20recherches.xlsx").Sheets("Recherches").Range("Table1[#All]") _
.AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=Range("A3:C4"), _
CopyToRange:=Range("A7:E7"), Unique:=False
Workbooks("http://bla.bla.com/Housing%20Specialists/Nouveaux%20tableaux/Tableau%20litiges.xlsx").Sheets("Litiges").Range("Table1[#All]"). _
AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=Range("A3:C4"), _
CopyToRange:=Range("F7:J7"), Unique:=False
Workbooks("http://bla.bla.com/Housing%20Specialists/Nouveaux%20tableaux/Tableau%20déménagements.xlsx").Sheets("Déménagements").Range( _
"Table1[#All]").AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=Range( _
"A3:C4"), CopyToRange:=Range("K7:O7"), Unique:=False
Workbooks("http://bla.bla.com/Housing%20Specialists/Nouveaux%20tableaux/Tableau%20départs.xlsx").Sheets("Départs").Range("Table1[#All]"). _
AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=Range("A3:C4"), _
CopyToRange:=Range("P7:Q7"), Unique:=False
Range("A7").Select
Range(Selection, Selection.End(xlDown)).Select
Range("A7:E13").Select
ActiveSheet.ListObjects.Add(xlSrcRange, Range("$A$7:$E$13"), , xlYes).Name = _
"Table2"
Range("Table2[#All]").Select
ActiveSheet.ListObjects("Table2").TableStyle = "TableStyleLight9"
Range("F7:J7").Select
Range(Selection, Selection.End(xlDown)).Select
ActiveSheet.ListObjects.Add(xlSrcRange, Range("$F$7:$J$8"), , xlYes).Name = _
"Table3"
ActiveCell.Range("A1:E2").Select
ActiveSheet.ListObjects("Table3").TableStyle = "TableStyleLight10"
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 3
Range("K7:O7").Select
Range(Selection, Selection.End(xlDown)).Select
ActiveSheet.ListObjects.Add(xlSrcRange, Range("$K$7:$O$8"), , xlYes).Name = _
"Table4"
ActiveCell.Range("A1:E2").Select
ActiveSheet.ListObjects("Table4").TableStyle = "TableStyleLight11"
ActiveWindow.ScrollColumn = 4
ActiveWindow.ScrollColumn = 5
ActiveWindow.ScrollColumn = 6
Range("P7:Q7").Select
Range(Selection, Selection.End(xlDown)).Select
ActiveSheet.ListObjects.Add(xlSrcRange, Range("$P$7:$Q$8"), , xlYes).Name = _
"Table5"
ActiveCell.Range("A1:B2").Select
ActiveSheet.ListObjects("Table5").TableStyle = "TableStyleLight14"
ActiveWindow.ScrollColumn = 5
ActiveWindow.ScrollColumn = 4
ActiveWindow.ScrollColumn = 3
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 1
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 3
ActiveWindow.ScrollColumn = 4
ActiveWindow.ScrollColumn = 5
ActiveWindow.ScrollColumn = 4
ActiveWindow.ScrollColumn = 3
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 1
End Sub
Bookmarks