Date | N° compte | Intitulé | TTC | TVA | HT |
03.01.20 | 627000 | PrlV Cotis Compte à composer | 2,14 |
N° compte | Intitulé | Débit | Crédit | |
03.01.20 | 627000 | PrlV Cotis Compte à composer | 2,14 | |
03.01.20 | 512000 | PrlV Cotis Compte à composer | 2,14 |
Date | N° compte | Intitulé | TTC | TVA | HT |
03.01.20 | 626100 | PayPal pour OVH | 50,62 | 8,44 | 42,18 |
Date | N° compte | Intitulé | Débit | Crédit |
03.01.20 | 626100 | PayPal pour OVH | 42,18 | |
03.01.20 | 445660 | PayPal pour OVH | 8,44 | |
03.01.20 | 512000 | PayPal pour OVH | 50,62 |
T1 = [A2].Resize(n, 6)
; la colonne A de la feuille contient 03.01.20 (vraie date au format jj.mm.aa) et devient automatiquement, dans la 1ère colonne du tableau T1 : 01.03.20 ; mon fichier v2 donne les bonnes dates du 03.01.20, mais la seule solution que j'ai trouvée à été de faire un tableau séparé pour les dates, ce qui rend assez complexe : 4 tableaux au lieu de 2 ! Option Explicit: Option Base 1
Sub Essai()
If ActiveSheet.Name <> "Feuil1" Then Exit Sub
Dim n&: n = Cells(Rows.Count, 1).End(3).Row: If n = 1 Then Exit Sub
Dim D01() As String, T01, D02() As String, T02, k As Byte, d$, i&, j&
n = n - 1: ReDim D01(n): T01 = [B2].Resize(n, 5)
For i = 1 To n
With [A1].Offset(i): D01(i) = Format(.Value, "dd.mm.yyyy"): End With
Next i
i = 2 * n + Application.Count(Columns(5))
ReDim D02(i): ReDim T02(5, i): j = 1
For i = 1 To n
D02(j) = D01(i): T02(1, j) = T01(i, 1): T02(2, j) = T01(i, 2): T02(3, j) = T01(i, 5): j = j + 1
k = 5 + 2 * (T01(i, 4) > 0)
If k = 3 Then
D02(j) = D01(i): T02(1, j) = "445660": T02(2, j) = T01(i, 2): T02(3, j) = T01(i, 4): j = j + 1
End If
D02(j) = D01(i): T02(1, j) = "512000": T02(2, j) = T01(i, 2): T02(4, j) = T01(i, k): j = j + 1
Next i
Application.ScreenUpdating = 0: Worksheets("Feuil2").Select: Columns("A:E").ClearContents
[A1] = "Date": [B1] = "N° compte": [C1] = "Intitulé": [D1] = "Débit": [E1] = "Crédit"
j = j - 1: [B2].Resize(j, 4) = Application.Transpose(T02)
For i = 1 To j
With [A1].Offset(i)
d = D02(i): .Value = Format(DateSerial(Right$(d, 4), Mid$(d, 4, 2), Left$(d, 2)), "dd.mm.yy")
End With
Next i
End Sub
Option Explicit: Option Base 1
Sub Essai()
If ActiveSheet.Name <> "Feuil1" Then Exit Sub
Dim n&: n = Cells(Rows.Count, 1).End(3).Row: If n = 1 Then Exit Sub
Dim D01() As String, T01, D02() As String, T02, k As Byte, d$, i&, j&
n = n - 1: ReDim D01(n): T01 = [B2].Resize(n, 5)
For i = 1 To n
With [A1].Offset(i): D01(i) = Format(.Value, "dd.mm.yyyy"): End With
Next i
i = 2 * n + Application.Count(Columns(5))
ReDim D02(i): ReDim T02(5, i): j = 1
For i = 1 To n
k = 3 - 2 * (T01(i, 4) > 0)
D02(j) = D01(i): T02(1, j) = T01(i, 1): T02(2, j) = T01(i, 2): T02(3, j) = T01(i, k): j = j + 1
If k = 5 Then
D02(j) = D01(i): T02(1, j) = "445660": T02(2, j) = T01(i, 2): T02(3, j) = T01(i, 4): j = j + 1
End If
D02(j) = D01(i): T02(1, j) = "512000": T02(2, j) = T01(i, 2): T02(4, j) = T01(i, 3): j = j + 1
Next i
Application.ScreenUpdating = 0: Worksheets("Feuil2").Select: Columns("A:E").ClearContents
[A1] = "Date": [B1] = "N° compte": [C1] = "Intitulé": [D1] = "Débit": [E1] = "Crédit"
j = j - 1: [B2].Resize(j, 4) = Application.Transpose(T02)
For i = 1 To j
With [A1].Offset(i)
d = D02(i): .Value = Format(DateSerial(Right$(d, 4), Mid$(d, 4, 2), Left$(d, 2)), "dd.mm.yy")
End With
Next i
End Sub
Très intéressant le #Table : je note précieusementUne autre proposition avec Power Query pour le fun