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 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
| Sub CopierBDD(chemin As String, fichier As String)
Set xlBook = Workbooks.Open(fichier)
Set xlListes = xlBook.Sheets("Listes")
Set xlBDD = xlBook.Sheets("BdD")
Dim inCalculationMode As Integer
Application.ScreenUpdating = False
inCalculationMode = Application.Calculation
Application.Calculation = xlCalculationManual
Set Wbk = Workbooks.Open(fichier)
With Wbk.Worksheets("Listes")
' ici sont créées les listes déroulantes
Set plage = .Range("A1:DV" & .Range("A65536").End(xlUp).Row)
End With
tbl = plage.Value
jcase = UBound(tbl, 1)
kcase = UBound(tbl, 2)
Set Sh = Wbk.Worksheets("Listes")
With ThisWorkbook.Worksheets("FeuilleCachée")
For i = 1 To jcase
For j = 1 To kcase
.Cells(i, j).Value = Sh.Cells(i, j).Value
.Cells(i, j).Interior.ColorIndex = Sh.Cells(i, j).Interior.ColorIndex
.Cells(i, j).Font.ColorIndex = Sh.Cells(i, j).Font.ColorIndex
Next j
Next i
End With
Wbk.Close False
Set Wbk = Nothing
Application.Calculation = inCalculationMode
Application.ScreenUpdating = True
Application.ThisWorkbook.Worksheets("FeuilleCachée").Visible = False
Sheets.Add
ActiveSheet.Name = "BdD"
' ici sont validées les listes déroulantes créées dans la feuille Listes
Set Wbk = Workbooks.Open(fichier)
With Wbk.Worksheets("BdD")
Set plage = .Range("A1:DV" & .Range("A65536").End(xlUp).Row)
End With
tbl = plage.Value
jcase = UBound(tbl, 1)
kcase = UBound(tbl, 2)
Set Sh = Wbk.Worksheets("BdD")
With ThisWorkbook.Worksheets("BdD")
' For i = 1 To jcase
For i = 1 To 2
' For j = 1 To kcase
For j = 1 To 2
.Cells(i, j).Value = Sh.Cells(i, j).Value
.Cells(i, j).Interior.ColorIndex = Sh.Cells(i, j).Interior.ColorIndex
.Cells(i, j).Font.ColorIndex = Sh.Cells(i, j).Font.ColorIndex
Next j
Next i
End With
'Ici la macro copie les valeurs mais sans les listes validées de son fichier d'origine, comment copier aussi cette liste et sa validation précédente?
Wbk.Close False
Set Wbk = Nothing
Application.Calculation = inCalculationMode
Application.ScreenUpdating = True
Application.ThisWorkbook.Worksheets("BdD").Visible = False
' BdD_piece
Sheets.Add
ActiveSheet.Name = "BdD_piece"
Set Wbk = Workbooks.Open(fichier)
With Wbk.Worksheets("BdD")
Set plage = .Range("A1:FZ" & .Range("A3").End(xlUp).Row)
End With
tbl = plage.Value
jcase = UBound(tbl, 1)
kcase = UBound(tbl, 2)
MsgBox jcase
MsgBox kcase
Set Sh = Wbk.Worksheets("BdD")
With ThisWorkbook.Worksheets("BdD_piece")
For i = 1 To jcase
For j = 1 To kcase
.Cells(i, j).Value = Sh.Cells(i, j).Value
.Cells(i, j).Interior.ColorIndex = Sh.Cells(i, j).Interior.ColorIndex
.Cells(i, j).Font.ColorIndex = Sh.Cells(i, j).Font.ColorIndex
' .Cells(i, j).Underline = Sh.Cells(i, j).Underline
'ajouter qu'il faut copier la largeur des cellules
Next j
Next i
End With
Wbk.Close False
Set Wbk = Nothing
Application.Calculation = inCalculationMode
Application.ScreenUpdating = True
UsfChoix.Hide
End Sub |
Partager