Import
ahmed.bouchemla
Messages postés
27
Statut
Membre
-
cs_Le Pivert Messages postés 8437 Statut Contributeur -
cs_Le Pivert Messages postés 8437 Statut Contributeur -
Bonjour
j'ai un fichier source txt que je veux importer sur un fichier excel via un bouton (donc une macro en VBA), bref le fichier en question doit être importer sur une feuille différente que celle qui contient le bouton d'import luis même.
un exemple de deux fichiers est sur les liens:
https://www.cjoint.com/c/FCcpqlXim8J
https://www.cjoint.com/c/FCcpqISJTpJ
Salutations
j'ai un fichier source txt que je veux importer sur un fichier excel via un bouton (donc une macro en VBA), bref le fichier en question doit être importer sur une feuille différente que celle qui contient le bouton d'import luis même.
un exemple de deux fichiers est sur les liens:
https://www.cjoint.com/c/FCcpqlXim8J
https://www.cjoint.com/c/FCcpqISJTpJ
Salutations
A voir également:
- Import
- Import favoris chrome - Guide
- Cd import - Forum Musique / Radio / Clip
- Dvd fr import signification - Forum Cinéma / Télé
- Les formalités import/export de votre colis sont suspendues en raison d'une facture manquante. nos services peuvent être amenés à vous contacter. - Forum Consommation & Internet
- Scribus import pdf - Forum Logiciels
5 réponses
voila les fichier exemple
https://www.cjoint.com/c/FCjtkdHBCZJ
https://www.cjoint.com/c/FCjtk48VNAJ
merci d'avance
https://www.cjoint.com/c/FCjtkdHBCZJ
https://www.cjoint.com/c/FCjtk48VNAJ
merci d'avance
Bonjour
Voila une macro pour import Txt
A+
Maurice
Voila une macro pour import Txt
Private Sub ChoixCumulTxt()
Dim dossier As FileDialog
ChoixChemin = ActiveWorkbook.Path & Application.PathSeparator
Set dossier = Application.FileDialog(msoFileDialogFilePicker)
With dossier
.AllowMultiSelect = False
.InitialFileName = ChoixChemin
.Title = "Choix d'un fichier Elise"
.Filters.Clear
.Filters.Add "Fichier Csv ", "*.txt", 1
If .Show = -1 Then
Chemin = .SelectedItems(1)
LireTxtCumul Chemin
End If
End With
Set dossier = Nothing
End Sub
Sub LireTxtCumul(NomFichier)
Dim Ar() As String
With Application
.ScreenUpdating = False
.EnableEvents = False
.Calculation = xlManual
End With
Feuil2.Select
Cells.Select
Selection.Delete Shift:=xlUp
Range("A1").Select
'Sep = "|"
Sep = vbTab
Lig = Range("A" & Rows.Count).End(xlUp).Row + 1
Lig = 1
' -----------------------------------------
Open NomFichier For Input As #1
Do While Not EOF(1)
Line Input #1, Chaine
Ar = Split(Chaine, Sep)
Col = 1
For X = LBound(Ar) To UBound(Ar)
Cells(Lig, Col) = Ar(X)
Col = Col + 1
Next
Lig = Lig + 1
Loop
Close #1
' --------- Mise en Forme -----------------
For L = 10 To Range("A" & Rows.Count).End(xlUp).Row
Range("C" & L).Value = Range("C" & L) * 1
Range("D" & L).Value = Range("D" & L) * 1
Range("E" & L).Value = Range("E" & L) * 1
Range("F" & L).Value = Range("F" & L) * 1
Range("M" & L).Value = Range("M" & L) * 1
Next
' -----------------------------------------
With Application
.ScreenUpdating = True
.Calculation = xlCalculationAutomatic
.EnableEvents = True
.CutCopyMode = False
.Goto [A1], True
End With
End Sub
A+
Maurice
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question
Ahmed