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 67 68 69 70
| Public Creation As Boolean
Public S1 As String
Public S2 As String
Dim Ligne_vide As Integer
Dim i As Integer
Type ColonneEtInfoSaisie
LibelleColonne As String
Colonne As Integer
InfoSaisie As String
End Type
Const x = 103
Global TabColInfo(x) As ColonneEtInfoSaisie
Sub Parcours_Creation_Projet()
Dim j As Integer
'---Pour le test à la place des usf
For j = 1 To x
TabColInfo(j).InfoSaisie = "P-AA-BBBB" & j
Next j
'---
Creation = True
If Creation = True Then
Call Trouve_Numeros_Des_Colonnes
Call Trouve_1ere_Ligne_Vide
Call Remplis_Cellules
End If
End Sub
Sub Trouve_Numeros_Des_Colonnes()
Dim Colonne_Existe As Range
For i = 0 To x
TabColInfo(i).LibelleColonne = Sheets("Listes").Cells(i + 2, Sheets("Listes").Range("A1", "Z1").Find("Libellés Colonnes", Range("A1"), , , , xlNext).Column)
Set Colonne_Existe = Sheets("Projets").Range("A1", "EZ4").Find(TabColInfo(i).LibelleColonne, Range("A1"), , , , xlNext)
If Not Colonne_Existe Is Nothing Then
TabColInfo(i).Colonne = Sheets("Projets").Range("A1", "EZ4").Find(TabColInfo(i).LibelleColonne, Range("A1"), , , , xlNext).Column
Set Colonne_Existe = Nothing
Else
TabColInfo(i).Colonne = 0
End If
Next i
End Sub
Sub Trouve_1ere_Ligne_Vide()
Ligne_vide = Sheets("Projets").UsedRange.Find("*", Cells(1, TabColInfo(0).Colonne), , , , xlPrevious).Row + 1
End Sub
Sub Remplis_Cellules()
Dim j As Integer
With Worksheets("Projets")
.Range("O1:AA1").Copy .Cells(Ligne_vide, 15)
.Range("AD1").Copy .Cells(Ligne_vide, 30)
.Range("AF1").Copy .Cells(Ligne_vide, 32)
.Range("B1").Copy .Cells(Ligne_vide, 2)
'rempli le fichier avec les valeurs saisies
For i = 1 To x
Debug.Print "i " & i & " - Colonne: " & TabColInfo(i).Colonne & " - InfoSaisie: " & TabColInfo(i).InfoSaisie
If TabColInfo(i).Colonne > 0 Then
.Cells(Ligne_vide, TabColInfo(i).Colonne).Value = TabColInfo(i).InfoSaisie
j = j + 1
End If
Next i
End With
MsgBox j & " =x, TabColInfo(i).Colonne>0 quelque soit i (pas de problème pour i=2)"
End Sub |
Partager