Decaller colonne macro
t
Bonjour,
J'ai fussioné 30 fichiers dans un fichier contenant 30 onglets.
ensuite j'impose une condition : '
condition Macro
If Sheets("Daily Report").Range("C8") = "At port" Then
Sheets("Sheet1").Range("B2") = Sheets("Daily Report").Range("C8").Value
End If
'copy parameters Macro
' date1 Macro
Sheets("Daily Report").Select
ActiveWindow.SmallScroll Down:=-48
Range("C7:D7").Select
Selection.Copy
Sheets("Sheet1").Select
Range("B3").Select
ActiveSheet.Paste
J'aimerai que ma macro pointe sur les 30 fichiers (j'ai trouvé le code suivant :
'Déclare la variable objet Worksheet
Dim Ws As Worksheet
'Boucle sur toutes les feuille de calcul du classeur. Les onglets graphiques ne sont pas pris
'en compte.
'ThisWorkbook correspond à l'objet classeur contenant la macro
For Each Ws In ThisWorkbook.Worksheets
'Renvoie le nom de chaque feuille
MsgBox Ws.Name
Next Ws
) mais du coup ca ecrit a chaque fois sur la meme colonne.
Comment fais je pour ecrire en B puis en C puis en D ... à chaque fois qu'on a "at port" ??
Merci
E
utilise la méthode cells
Cells(1,1) Correspond à A1
Cells(1,2) Correspond à B1
Il te suffit d'incrémenter la colonne de 1 dans ta boucle
t
j'ai jamais fait de boucle d'ingrementation
J'incremente à quel endroit de mon code ? ce que je copie ou la ou je lui dis de faire sur toutes les feuilles ?
je veux bien un peu d'aide
t
Je vous joint mon code en entier si qqn peut/veut bien m'aider :
Sub Status()
' condition Macro
' il y a sheet1, sheet2, sheet3 en realité, pas de "daily report"
If Sheets("Daily Report").Range("C8") = "At port" Then
Sheets("Sheet1").Range("B2") = Sheets("Daily Report").Range("C8").Value
End If
'copy parameters Macro
'Selection date
Sheets("Daily Report").Select
ActiveWindow.SmallScroll Down:=-48
Range("C7:D7").Select
Selection.Copy
Sheets("Sheet1").Select
Range("B3").Select
ActiveSheet.Paste
'Selection Configuration
Sheets("Daily Report").Select
Range("D13").Select
Selection.Copy
Sheets("Sheet1").Select
Range("B4").Select
ActiveSheet.Paste
'Selection Puissance
Sheets("Daily Report").Select
ActiveWindow.SmallScroll Down:=42
Range("D15").Select
Selection.Copy
Sheets("Sheet1").Select
Range("B5").Select
ActiveSheet.Paste
'Selection consomation
Sheets("Daily Report").Select
ActiveWindow.SmallScroll Down:=-48
Range("D69").Select
Selection.Copy
Sheets("Sheet1").Select
Range("B6").Select
ActiveSheet.Paste
'Mise en page
Range("A1:C6").Select
Application.CutCopyMode = False
With Selection.Interior
.Pattern = xlNone
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
Selection.Borders(xlEdgeLeft).LineStyle = xlNone
Selection.Borders(xlEdgeTop).LineStyle = xlNone
Selection.Borders(xlEdgeBottom).LineStyle = xlNone
Selection.Borders(xlEdgeRight).LineStyle = xlNone
Selection.Borders(xlInsideVertical).LineStyle = xlNone
Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
Range("B3:C3").Select
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = True
End With
Selection.UnMerge
Range("A1:B6").Select
Range("B6").Activate
With Selection
.HorizontalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Selection.Font.Bold = True
Selection.Font.Bold = False
With Selection.Font
.Size = 11
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.TintAndShade = 0
End With
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
'modification police ecriture
Range("A1:B6").Select
With Selection.Font
.Name = "Calibri"
.Size = 11
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.TintAndShade = 0
.ThemeFont = xlThemeFontMinor
End With
End Sub