Moderatori: Anthony47, Flash30005
Private Sub Worksheet_Change(ByVal Target As Range)
ur = Cells(Rows.Count, 1).End(xlUp).Row
For i = 1 To 35
If Cells(2, i) = "" Then uc = i: Exit For
Next i
If Not Intersect(Target, Range("C3:C183")) Is Nothing Then
If UCase(Cells(Target.Row, 3)) = "X" Then
Range("D" & Target.Row & ":AH" & Target.Row).ClearContents
For j = 1 To 3
Randomize
c = Application.WorksheetFunction.RandBetween(4, uc)
Cells(Target.Row, c) = "X"
Next j
ElseIf Cells(Target.Row, 3) = "" Then
Range("D" & Target.Row & ":AH" & Target.Row).ClearContents
End If
End If
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
ur = Cells(Rows.Count, 1).End(xlUp).Row
For i = 4 To 35
If Cells(2, i) = "" Then uc = i - 1: Exit For
Next i
Dim myC As Range
Randomize
Application.EnableEvents = False
For Each myC In Target
If Not Intersect(myC, Range("C3:C183")) Is Nothing Then
If UCase(Cells(myC.Row, 3)) = "X" Then
Range("D" & myC.Row & ":AH" & myC.Row).ClearContents
For j = 1 To 3
c = Application.WorksheetFunction.RandBetween(4, uc)
If Cells(myC.Row, c) = "" Then
Cells(myC.Row, c) = "X"
Else
j = j - 1
End If
Next j
ElseIf Cells(myC.Row, 3) = "" Then
Range("D" & myC.Row & ":AH" & myC.Row).ClearContents
End If
End If
Next myC
Application.EnableEvents = True
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
ur = Cells(Rows.Count, 1).End(xlUp).Row
For i = 4 To 35
If Cells(2, i) = "" Then uc = i - 1: Exit For
Next i
Dim myC As Range
Randomize
Application.EnableEvents = False
For Each myC In Target
If Not Intersect(myC, Range("g3:g183")) Is Nothing Then
If UCase(Cells(myC.Row, 3)) = "X" Then
Range("H" & myC.Row & ":AL" & myC.Row).ClearContents
For j = 1 To 3
c = Application.WorksheetFunction.RandBetween(4, uc)
If Cells(myC.Row, c) = "" Then
Cells(myC.Row, c) = "X"
Else
j = j - 1
End If
Next j
ElseIf Cells(myC.Row, 3) = "" Then
Range("H" & myC.Row & ":AL" & myC.Row).ClearContents
End If
End If
Next myC
Application.EnableEvents = True
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
ur = Cells(Rows.Count, 1).End(xlUp).Row
For i = 8 To 40 '**Da colonna H
If Cells(2, i) = "" Then uc = i - 1: Exit For
Next i
Dim myC As Range
Randomize
Application.EnableEvents = False
For Each myC In Target
If Not Intersect(myC, Range("g3:g183")) Is Nothing Then
If UCase(Cells(myC.Row, "G")) = "X" Then '**
Range("H" & myC.Row & ":AL" & myC.Row).ClearContents
For j = 1 To 3
c = Application.WorksheetFunction.RandBetween(8, uc) '**
If Cells(myC.Row, c) = "" Then
Cells(myC.Row, c) = "X"
Else
j = j - 1
End If
Next j
ElseIf Cells(myC.Row, "G") = "" Then '**
Range("H" & myC.Row & ":AL" & myC.Row).ClearContents
End If
End If
Next myC
Application.EnableEvents = True
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
Dim hCols As String, UC As Long, xCol As String
Dim myC As Range, UR As Long, nCol As String
'
hCols = "H2:AL2" '<<< L'area sotto cui inserire le 3 X
xCol = "B" '<<< La colonna dove si imposta la X
nCol = "A" '<<< La colonna con i nominativi
'
For Each myC In Range(hCols)
If myC.Value = "" Then UC = myC.Column - 1: Exit For
Next myC
If UC = 0 Then
UC = Range(hCols).Cells(1, 1).Column + Range(hCols).Columns.Count - 1
End If
UR = Cells(Rows.Count, nCol).End(xlUp).Row
Randomize
Application.EnableEvents = False
For Each myC In Target
If Not Intersect(myC, Cells(3, xCol).Resize(UR, 1)) Is Nothing Then
If UCase(Cells(myC.Row, xCol)) = "X" Then
Range(hCols).Offset(myC.Row - Range(hCols).Cells(1, 1).Row, 0).ClearContents
For j = 1 To 3
c = Application.WorksheetFunction.RandBetween(Range(hCols).Cells(1, 1).Column, UC)
If Cells(myC.Row, c) = "" Then
Cells(myC.Row, c) = "X"
Else
j = j - 1
End If
Next j
ElseIf Cells(myC.Row, xCol) = "" Then
Range(hCols).Offset(myC.Row - Range(hCols).Cells(1, 1).Row, 0).ClearContents
End If
End If
Next myC
Application.EnableEvents = True
End Sub
Torna a Applicazioni Office Windows
Rimozione parziale di caratteri nella cella Autore: Ricky0185 |
Forum: Applicazioni Office Windows Risposte: 4 |
macro excel inserire caratteri nella cella e tutto maiuscolo Autore: turbonet |
Forum: Applicazioni Office Windows Risposte: 2 |
codificare i caratteri del testo di una cella Autore: teto021162 |
Forum: Applicazioni Office Windows Risposte: 25 |
Visitano il forum: Nessuno e 18 ospiti