Fichier txt dans excel
Résolu/Fermé
A voir également:
- Fichier txt dans excel
- Fichier rar - Guide
- Liste déroulante excel - Guide
- Fichier host - Guide
- Comment ouvrir un fichier epub ? - Guide
- Comment réduire la taille d'un fichier - Guide
1 réponse
J'y arrive presque
Donc pour l'instant j'ai fait cela mais la boucle a du mal à fonctionner.
Si vous voyez de grosses erreurs n'hésitez pas , merci ...(même des petites )
[CODE]
Sub remplir(feuille As Worksheet, nom As String, con As String, dest As Range)
With feuille.QueryTables.Add(con, dest)
.Name = nom
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
End Sub
[\CODE]
[CODE]
Sub feuilles()
Dim NewSheet As Worksheet
Dim SName As String
Dim sURl As String
Dim Boucle As Integer
DerniereValeur = Worksheets("Feuil1").Range("A1:A50").Find("").Row
For Boucle = 1 To DerniereValeur - 1
SName = Worksheets("Feuil1").Range("A" & Boucle).Text
sURl = Worksheets("Feuil1").Range("B" & Boucle).Text
Set NewSheet = Worksheets(SName)
If Worksheets(SName).Name = SName Then
Else
Call Worksheets.Add(After:=Worksheets(Worksheets.Count - 1))
Set NewSheet = Worksheets.Item(Worksheets.Count - 1)
NewSheet.Name = SName
End If
Call remplir(NewSheet, SName, sURl, NewSheet.Range("A1"))
Next
Set NewSheet = Nothing
End Sub
[\CODE]
Donc pour l'instant j'ai fait cela mais la boucle a du mal à fonctionner.
Si vous voyez de grosses erreurs n'hésitez pas , merci ...(même des petites )
[CODE]
Sub remplir(feuille As Worksheet, nom As String, con As String, dest As Range)
With feuille.QueryTables.Add(con, dest)
.Name = nom
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
End Sub
[\CODE]
[CODE]
Sub feuilles()
Dim NewSheet As Worksheet
Dim SName As String
Dim sURl As String
Dim Boucle As Integer
DerniereValeur = Worksheets("Feuil1").Range("A1:A50").Find("").Row
For Boucle = 1 To DerniereValeur - 1
SName = Worksheets("Feuil1").Range("A" & Boucle).Text
sURl = Worksheets("Feuil1").Range("B" & Boucle).Text
Set NewSheet = Worksheets(SName)
If Worksheets(SName).Name = SName Then
Else
Call Worksheets.Add(After:=Worksheets(Worksheets.Count - 1))
Set NewSheet = Worksheets.Item(Worksheets.Count - 1)
NewSheet.Name = SName
End If
Call remplir(NewSheet, SName, sURl, NewSheet.Range("A1"))
Next
Set NewSheet = Nothing
End Sub
[\CODE]
17 avril 2008 à 14:30
Sub remplir(feuille As Worksheet, nom As String, con As String, dest As Range)
With feuille.QueryTables.Add(con, dest)
.Name = nom
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = True
.PreserveFormatting = False
.RefreshOnFileOpen = False
.BackgroundQuery = True
'entire ou delete pour mise à jour
.RefreshStyle = xlInsertEntireCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
End Sub
Sub feuilles()
Dim NewSheet As Worksheet
Dim SName As String
Dim sURl As String
Dim Boucle As Integer
Dim DerniereValeur As Long
DerniereValeur = Worksheets("Feuil1").Range("A1:A50").Find("").Row - 1
MsgBox DerniereValeur
For Boucle = 1 To DerniereValeur
SName = Worksheets("Feuil1").Range("A" & Boucle).Text
sURl = "url;" & Worksheets("Feuil1").Range("B" & Boucle).Text
Set NewSheet = Worksheets.Add(After:=Worksheets(Worksheets.Count))
NewSheet.Name = SName
Call remplir(NewSheet, SName, sURl, NewSheet.Range("A1"))
Next
Set NewSheet = Nothing
End Sub