Bonjour,
J'ai un petit problème qui vient d'apparaitre sur l'une de mes macros et je ne trouve pas comment le résoudre:
L'erreur se trouve sur cette ligne :
n = n + 1: réf(n) = WorksheetFunction.Index(aa, i, 0)
Des idées?
'================================================================================================================
'Copier tableau dans "Liste étiquettes"
'================================================================================================================
Sheets("Analyse de risque (2)").Select
Columns("B:B").Delete
For Each curShape In ActiveSheet.Shapes
curShape.Delete
Next curShape
'----------------Incrémenter doublons--------------------------
Rows("1:1").Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Dim aa, réf(), n&, i&, j%, réfer$
aa = ActiveSheet.Range("A1").CurrentRegion
n = WorksheetFunction.Sum(WorksheetFunction.Index(aa, 0, 1))
ReDim réf(n): n = 0
For i = 2 To UBound(aa)
If aa(i, 1) = 1 Then
n = n + 1: réf(n) = WorksheetFunction.Index(aa, i, 0)
Else
réfer = aa(i, 2) & " #"
For j = 1 To aa(i, 1)
aa(i, 2) = réfer & Format(j, "000")
n = n + 1: réf(n) = WorksheetFunction.Index(aa, i, 0)
Next j
End If
Next i
réf(0) = WorksheetFunction.Index(aa, 1, 0)
With Worksheets.Add(after:=ActiveSheet).Range("A1").Resize(n + 1, UBound(aa, 2))
.Value = WorksheetFunction.Transpose(WorksheetFunction.Transpose(réf))
.Columns.AutoFit
.HorizontalAlignment = xlCenter
.Borders.Weight = xlThin
End With
ActiveSheet.Name = "Liste étiquettes 2"
Merci d'avance pour votre aide.