Je recherche une astuce pour avoir une numérotation automatique soit +1 par rapport au départ. J'utilise cette macro mais je la trouve trop complexe. Avez vous une solution plus simple ?
Numauto est une cellule nommée mais peut être aussi A1
Private Sub Workbook_open()
If ActiveWorkbook.Path = '' Then
[numauto] = [numauto] + 1
ActiveWorkbook.Saved = True
ActiveWorkbook.SaveCopyAs (Application.TemplatesPath & 'numauto avec macro.xlt')
End If
End Sub
Private Sub Workbook_BeforeClose(cancel As Boolean)
chemXlt = Application.TemplatesPath & 'numauto avec macro.xlt'
If ActiveWorkbook.Path = '' Then
Set wbk = Workbooks.Open(chemXlt)
With wbk.ActiveSheet
.Range('numauto ') = .Range('numauto ') - 1
End With
wbk.Close True
End If
End Sub
Numauto est une cellule nommée mais peut être aussi A1
Private Sub Workbook_open()
If ActiveWorkbook.Path = '' Then
[numauto] = [numauto] + 1
ActiveWorkbook.Saved = True
ActiveWorkbook.SaveCopyAs (Application.TemplatesPath & 'numauto avec macro.xlt')
End If
End Sub
Private Sub Workbook_BeforeClose(cancel As Boolean)
chemXlt = Application.TemplatesPath & 'numauto avec macro.xlt'
If ActiveWorkbook.Path = '' Then
Set wbk = Workbooks.Open(chemXlt)
With wbk.ActiveSheet
.Range('numauto ') = .Range('numauto ') - 1
End With
wbk.Close True
End If
End Sub