orectum
Messages postés4Date d'inscriptionjeudi 17 juillet 2008StatutMembreDernière intervention22 juillet 2008
-
17 juil. 2008 à 14:00
mortalino
Messages postés6786Date d'inscriptionvendredi 16 décembre 2005StatutMembreDernière intervention21 décembre 2011
-
17 juil. 2008 à 14:43
Bonjour,
J'utilise des macros depuis peu, et je rencontre un problème, à chaque fois que je clique sur mon bouton, la date de mon PC change (outlook s'active avec toutes mes tâches à faire...)
Voici une partie du code, je pense que c'est à ce niveau que ça modifie la date :
glob = InputBox("Globale O/N")If glob "N" Or glob "n" Then
GoTo saisiedate
Else
GoTo suite
End If
saisiedate:
Date = InputBox("Saisir la date à éditer ")
Cells(1, 12) = Date
J'utilise ce fichier pour imprimer des commandes, je dois faire la distinction entre la commande globale et la commande journalière (c'est la que j'entre ma date pour récupérer uniquement les données de la date en question, les données sont copiées dans un autre onglet d'excel)
Je suis nouveau et je ne sais pas trop ce que je dois vous dire de plus ...
orectum
Messages postés4Date d'inscriptionjeudi 17 juillet 2008StatutMembreDernière intervention22 juillet 2008 17 juil. 2008 à 14:35
Je viens d'essayer ce que tu m'a dis Renfield, mais il ne reconnait pas la valeur, il ne trouve aucune ligne correspondant a la date
Je viens de mettre toutes les lignes de codes, si ça peut vous aider...
Merci
Sub Récap_commande()
Range(Rows(2), Rows(6000)).EntireRow.AutoFit
' tri par date
Rows("2:6000").Select
Selection.Sort Key1:=Range("J2"), Order1:=xlAscending, Key2:=Range("B2") _
, Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase:= _
False, Orientation:=xlTopToBottom
glob = InputBox("Globale O/N")If glob "N" Or glob "n" Then
GoTo saisiedate
Else
GoTo suite
End If
saisiedate:
Date = InputBox("Saisir la date à éditer ")
Cells(1, 12) = Date
' fait une copie de l'onglet
Cells.Select
Selection.Copy
Sheets("Données bis").Select
Cells.Select
ActiveSheet.Paste
i = 2
Do While Cells(i, 1) <> ""
If Cells(i, 10) <> Cells(1, 12) Then
Rows(i).Delete Shift:=xlUp
i = i - 1
End If
i = i + 1
Loop
GoTo comjour
suite:
' fait la commande globale
' reprise ancien programme
For i = 2 To 6000
If Not (IsEmpty(Cells(i, 10))) Then
Rows(i).Font.ColorIndex = 49
End If
Next i
ActiveSheet.PivotTableWizard SourceType:=xlDatabase, SourceData:= _
"DONNEES!R1C2:R6000C10", TableDestination:="", TableName:= _
"Tableau croisé dynamique3"
With ActiveSheet.PivotTables("Tableau croisé dynamique3").PivotFields( _
"REF_CHANT")
.Subtotals = Array(False, False, False, False, False, False, False, False, False, _
False, False, False)
.PivotItems("(vide)").Visible = False
End With
With ActiveSheet.PivotTables("Tableau croisé dynamique3").PivotFields( _
"DESC_CHANT")
.Subtotals = Array(False, False, False, False, False, False, False, False, False, _
False, False, False)
.PivotItems("(vide)").Visible = False
End With
With ActiveSheet.PivotTables("Tableau croisé dynamique3").PivotFields("REF_BOB" _
)
.PivotItems("(vide)").Visible = False
End With
With ActiveSheet.PivotTables("Tableau croisé dynamique3").PivotFields("CDC")
.Subtotals = Array(False, False, False, False, False, False, False, False, False, _
False, False, False)
.PivotItems("(vide)").Visible = False
End With
With ActiveSheet.PivotTables("Tableau croisé dynamique3").PivotFields( _
"DATE_EXPE")
.Subtotals = Array(False, False, False, False, False, False, False, False, False, _
False, False, False)
.PivotItems("(vide)").Visible = False
End With
ActiveSheet.PivotTables("Tableau croisé dynamique3").AddFields RowFields:= _
Array("REF_BOB", "REF_CHANT", "DESC_CHANT", "Données"), ColumnFields:= _
"DATE_EXPE", PageFields:="CDC"
With ActiveSheet.PivotTables("Tableau croisé dynamique3").PivotFields("QTE")
.Orientation = xlDataField
.Name = " "
.Function = xlSum ' fdsgfsdjhfdhjfsdj
.Position = 1
End With
With ActiveSheet.PivotTables("Tableau croisé dynamique3").PivotFields("QTE_BOB" _
)
.Orientation = xlDataField
.Name = "Somme Qte"
.Function = xlSum
End With
GoTo suitetableau
comjour:
' commande à la journée
' fait la commande à la journée
ActiveSheet.PivotTableWizard SourceType:=xlDatabase, SourceData:= _
"Données bis!R1C2:R6000C10", TableDestination:="", TableName:= _
"Tableau croisé dynamique3"
With ActiveSheet.PivotTables("Tableau croisé dynamique3").PivotFields( _
"REF_CHANT")
.Subtotals = Array(False, False, False, False, False, False, False, False, False, _
False, False, False)
.PivotItems("(vide)").Visible = False
End With
With ActiveSheet.PivotTables("Tableau croisé dynamique3").PivotFields( _
"DESC_CHANT")
.Subtotals = Array(False, False, False, False, False, False, False, False, False, _
False, False, False)
.PivotItems("(vide)").Visible = False
End With
With ActiveSheet.PivotTables("Tableau croisé dynamique3").PivotFields("REF_BOB" _
)
.PivotItems("(vide)").Visible = False
End With
With ActiveSheet.PivotTables("Tableau croisé dynamique3").PivotFields("CDC")
.Subtotals = Array(False, False, False, False, False, False, False, False, False, _
False, False, False)
.PivotItems("(vide)").Visible = False
End With
With ActiveSheet.PivotTables("Tableau croisé dynamique3").PivotFields( _
"DATE_EXPE")
.Subtotals = Array(False, False, False, False, False, False, False, False, False, _
False, False, False)
.PivotItems("(vide)").Visible = False
End With
ActiveSheet.PivotTables("Tableau croisé dynamique3").AddFields RowFields:= _
Array("REF_BOB", "REF_CHANT", "DESC_CHANT", "Données"), ColumnFields:= _
"DATE_EXPE", PageFields:="CDC"
With ActiveSheet.PivotTables("Tableau croisé dynamique3").PivotFields("QTE")
.Orientation = xlDataField
.Name = " "
.Function = xlSum ' fdsgfsdjhfdhjfsdj
.Position = 1
End With
With ActiveSheet.PivotTables("Tableau croisé dynamique3").PivotFields("QTE_BOB" _
)
.Orientation = xlDataField
.Name = "Somme Qte"
.Function = xlSum
End With
suitetableau:
' mise en forme
Cells.Select
Selection.NumberFormat = "0"
ActiveWindow.DisplayZeros = False
Rows("4:4").Select
Selection.NumberFormat = "d-mmm"
For i = 5 To 1000
If IsEmpty(Cells(i, 2)) And Left(Cells(i, 1), 3) <> "Som" _
And Left(Cells(i, 1), 3) <> "Tot" Then
Rows(i).EntireRow.Select
Selection.EntireRow.Hidden = True
End If
If Left(Cells(i, 1), 3) = "Som" Then
Rows(i).Select
Selection.Font.Bold = True
With Selection.Font
.Name = "Arial"
.FontStyle = "Gras"
.Size = 12
.ColorIndex = xlAutomatic
End With
Selection.Font.Italic = True
End If
If Left(Cells(i, 1), 9) = "Total Som" Then
GoTo finfor
End If
Next i
finfor: