Tout tout nouveau avec Apps Script.
J'ai un fichier d'inscription à différents évènements avec un quota de 10 pour chacun.
J'ai obtenu de JExcel2fr une macro vba me permettant de verrouiller les cellules de la colonne concernée lorsque le quota est atteint (voir commentaire dans le code) :
- la 11° inscription est effacée et un MsgBox apparaît.
Option Explicit Private Sub Worksheet_Change(ByVal Target As Range)
' JExcel2fr 19/09/24
' https://forum.excel-pratique.com/excel/verrouiller-plusieurs-plages-separement-195615
Dim Plg As Range
If Not Intersect(Range("B4:B24,C4:C24,D4:D24,E4:E24,F4:F24,G4:G24,H4:H24,I4:I24,J4:J24,K4:K24,L4:L24,M4:M24,N4:N24"), Target) Is Nothing Then
Set Plg = Range(Cells(4, Target.Column), Cells(24, Target.Column))
If WorksheetFunction.CountA(Plg) > 10 Then
' Optionnel
Application.EnableEvents = False
Target.ClearContents
Application.EnableEvents = True MsgBox "10 places maximum SVP", vbCritical, "OUPS..."
' Demande initiale
Plg.Locked = True
Else Plg.Locked = False
End If
End If
Set Plg = Nothing
End Sub
Y a-t-il moyen d'adapter ce code sur Apps Script , SVP ?
https://docs.google.com/spreadsheets/d/1WWHbz-k6FKVnnFkrwNKukoPRJHuGZI-_yw7dxHBhCYo/edit?usp=sharing
Sur ce fichier, j'ai simplement ajouté une MFC qui colore une colonne dès que la 10° inscription est validée. Mais les suivantes sont quand même acceptées...
Merci