Forum Discussion
adambc
1 year agoFrequent Visitor
Automate creating new queries ...
Forgive me if I don't go into the detail of why I need to do the following, just trust me that there is a good reason! I have 78 .xlsx files stored in a single folder OneDrive environment ... - ...
- 1 year ago
Bonjour adambc
Je réponds en français, c'est plus simple pour moi
C'est possible avec une requête Power Query chargée dans le modèle de données (Power Pivot) et une petite macro VBA pour modifier chaque table en DAXLa requête Power Query doit regrouper vos 78 fichiers et la macro va filtrer sur le nom de chaque fichier
A adapter bien évidemment
code de la macro
Sub Duplique()
For Each Nom In Range("Tableau1[Column1]")
Sheets.Add After:=ActiveSheet
ActiveSheet.Name = Nom
Set Data = ActiveSheet.ListObjects.Add(SourceType:=4, Source:=ActiveWorkbook.Connections("Requête - Tableau1"), Destination:=Range("$A$1"))
Data.TableObject.WorkbookConnection.OLEDBConnection.CommandText = Array("EVALUATE FILTER(Tableau1, [Column1]=""" & Nom & """)")
Data.TableObject.WorkbookConnection.OLEDBConnection.CommandType = xlCmdDAX
Data.Refresh
Next Nom
End SubVoir la vidéo en pièce jointe
Stéphane
v-priyankata
1 year agoCommunity Support
Hi adambc
I hope this information is helpful. Please let me know if you have any further questions or if you'd like to discuss this further. If this answers your question, please Accept it as a solution and give it a 'Kudos' so others can find it easily.
Thank you.