Bonjour à tous,
J'ai ce code vba :
Private TEST As Boolean
Private O1 As Object
Private PL As Range
Private Sub UserForm_Initialize()
Dim DL As Integer
Dim PLD As Range
Dim D As Object
Dim CEL As Range
Set O1 = Sheets("Commande-Controle")
DL = O1.Cells(Application.Rows.Count, 1).End(xlUp).Row
Set PLD = O1.Range("A3:A" & DL)
Set PL = O1.Range("D3:I" & DL)
Set D = CreateObject("Scripting.Dictionary")
For Each CEL In PLD
D(CEL.Value) = ""
Next CEL
Me.ComboBox1.List = D.keys
End Sub
Private Sub ComboBox1_Change()
Dim O2 As Object
Dim PLV As Range
Dim N As String
If TEST = True Then Exit Sub
TEST = True
Application.ScreenUpdating = False
Me.ComboBox1.Value = DateSerial(Year(Me.ComboBox1.Value), Month(Me.ComboBox1.Value), Day(Me.ComboBox1.Value))
N = Replace(Me.ComboBox1.Value, "/", "_")
On Error Resume Next
Set O2 = Sheets(N)
If Err = 0 Then MsgBox "Date déjà effectuée !": End
If Err <> 0 Then
Err.Clear
Sheets.Add After:=Sheets(Sheets.Count)
ActiveSheet.Name = N
Set O2 = ActiveSheet 'définit l'onglet O2
End If
On Error GoTo 0
O1.Range("D2:I2").Copy O2.Range("A1")
O1.ListObjects("RECAP").Range.AutoFilter Field:=1, Criteria1:=Me.ComboBox1.Value
Set PLV = PL.SpecialCells(xlCellTypeVisible)
PLV.Copy O2.Cells(Application.Rows.Count, 1).End(xlUp).Offset(1, 0)
O1.Range("A3").AutoFilter
Unload Me
O2.Select
Application.ScreenUpdating = True
End Sub
Il fonctionne bien, soit userform qui ouvre une liste déroulante dans laquelle, je choisis une date et les colonnes D à I sont copiées dans une nouvelle feuille qui est créée.
Mon problème est que j'ai des formules dans certaines colonnes et ce sont les formules qui sont copiées et non les valeurs
Merci de votre aide.
J'ai ce code vba :
Private TEST As Boolean
Private O1 As Object
Private PL As Range
Private Sub UserForm_Initialize()
Dim DL As Integer
Dim PLD As Range
Dim D As Object
Dim CEL As Range
Set O1 = Sheets("Commande-Controle")
DL = O1.Cells(Application.Rows.Count, 1).End(xlUp).Row
Set PLD = O1.Range("A3:A" & DL)
Set PL = O1.Range("D3:I" & DL)
Set D = CreateObject("Scripting.Dictionary")
For Each CEL In PLD
D(CEL.Value) = ""
Next CEL
Me.ComboBox1.List = D.keys
End Sub
Private Sub ComboBox1_Change()
Dim O2 As Object
Dim PLV As Range
Dim N As String
If TEST = True Then Exit Sub
TEST = True
Application.ScreenUpdating = False
Me.ComboBox1.Value = DateSerial(Year(Me.ComboBox1.Value), Month(Me.ComboBox1.Value), Day(Me.ComboBox1.Value))
N = Replace(Me.ComboBox1.Value, "/", "_")
On Error Resume Next
Set O2 = Sheets(N)
If Err = 0 Then MsgBox "Date déjà effectuée !": End
If Err <> 0 Then
Err.Clear
Sheets.Add After:=Sheets(Sheets.Count)
ActiveSheet.Name = N
Set O2 = ActiveSheet 'définit l'onglet O2
End If
On Error GoTo 0
O1.Range("D2:I2").Copy O2.Range("A1")
O1.ListObjects("RECAP").Range.AutoFilter Field:=1, Criteria1:=Me.ComboBox1.Value
Set PLV = PL.SpecialCells(xlCellTypeVisible)
PLV.Copy O2.Cells(Application.Rows.Count, 1).End(xlUp).Offset(1, 0)
O1.Range("A3").AutoFilter
Unload Me
O2.Select
Application.ScreenUpdating = True
End Sub
Il fonctionne bien, soit userform qui ouvre une liste déroulante dans laquelle, je choisis une date et les colonnes D à I sont copiées dans une nouvelle feuille qui est créée.
Mon problème est que j'ai des formules dans certaines colonnes et ce sont les formules qui sont copiées et non les valeurs
Merci de votre aide.