[VBA-E] Problème de format d'importation d'un fichier texte vers Excel via une macro
Bonjour !
Désolée pour ce titre aussi long mais mon problème est plutôt compliqué !!!
J'importe des données d'une base de données importante. Ces données passent dans un fichier texte, puis sont renvoyées dans un fichier Excel pour plus de clarté.
Une colonne correspond à un attribut !
Certains attributs contiennent des paragraphes avec des retour-charriot !
Et lors du passage du fichier texte au fichier Excel, il y a un bug : au moment du premier retour-charriot, les données n'apparaissent plus... :(
On m'a passé une fonction qui permettrait d'insérer correctement les données mais je ne comprends pas tout et la personne n'est pas disponible actuellement... Pourriez-vous m'aider à la comprendre et voir si je peux m'en servir...
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
| Public Function NewLastFileRow(Fichier, FirstRowIndex, LastRowIndex) As Integer
Dim indice As Integer
Dim index As Integer
Dim IndexUpdate As Integer
Dim table(30) As String
Dim rngCurrentCell As Range
table(0) = "a"
table(1) = "b"
table(2) = "c"
table(3) = "d"
table(4) = "e"
table(5) = "f"
table(6) = "g"
table(7) = "h"
table(8) = "i"
table(9) = "j"
table(10) = "k"
table(11) = "l"
table(12) = "m"
table(13) = "n"
table(14) = "o"
table(15) = "p"
table(16) = "q"
table(17) = "r"
table(18) = "s"
table(19) = "t"
table(20) = "u"
table(21) = "v"
table(22) = "w"
table(23) = "X"
table(24) = "Y"
table(25) = "z"
table(26) = "AA"
table(27) = "AB"
table(28) = "AC"
table(29) = "AD"
For indice = FirstRowIndex To LastRowIndex
For index = 0 To 29
With Fichier.Worksheets(1).Range(table(index) & indice)
If .MergeCells Then
.MergeArea.UnMerge
End If
End With
Next
Next
NewLastFileRow = LastRowIndex
IndexUpdate = FirstRowIndex + 1
For indice = (FirstRowIndex + 1) To LastRowIndex
If Fichier.Worksheets(1).Cells(IndexUpdate, 2).Value = "" Then
Fichier.Worksheets(1).Cells((IndexUpdate - 1), 30).Value = Fichier.Worksheets(1).Cells((IndexUpdate - 1), 30).Value & " " & Fichier.Worksheets(1).Cells(IndexUpdate, 30).Value
Set rngCurrentCell = Fichier.Worksheets(1).Range("a" & IndexUpdate)
rngCurrentCell.EntireRow.Delete
NewLastFileRow = NewLastFileRow - 1
Else
IndexUpdate = IndexUpdate + 1
End If
Next
End Function |
SVP AIDEZ-MOI !!!!!!!