
Sub controllanotte()
'On Error Resume Next
If ActiveCell.Offset(0, 1) = "N" Then
MsgBox " Attenzione il giorno seguente è una Notte "
Else
If ActiveCell.Offset(1, -6) = "N" Then
MsgBox " Attenzione il giorno seguente è una Notte "
Else
If ActiveCell.Offset(1, -7) = "N" Then
MsgBox " Attenzione il giorno seguente è una Notte "
End If
End If
End If
'Resume
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Range("A3") = "" Then Exit Sub
Dim T, G, X, Y, B, J 'Mattina
Dim S, Q, R, F 'Notte
Dim Z, K, W, A 'Pomerigio
For col = 3 To 9
T = 0 ' Inizio Mattina
For Each X In Range(Cells(4, col), Cells(11, col))
If Right(X.Text, 1) = "M" Or Left(X.Text, 1) = "M" Then T = T + 1
Next
G = 0
For Each Y In Range(Cells(17, col), Cells(36, col))
If Right(Y.Text, 1) = "M" Or Left(Y.Text, 1) = "M" Then G = G + 1
Next
B = 0
For Each J In Range(Cells(4, col), Cells(36, col))
If J = "Ma" Then B = B + 1
Next
Cells(45, col) = G + T - B 'Fine Mattina
Z = 0 ' Inizio Pomeriggio
For Each K In Range(Cells(4, col), Cells(11, col))
If Right(K.Text, 1) = "P" Or Left(K.Text, 1) = "P" Then Z = Z + 1
Next
W = 0
For Each A In Range(Cells(17, col), Cells(36, col))
If Right(A.Text, 1) = "P" Or Left(A.Text, 1) = "P" Then W = W + 1
Next
Cells(46, col) = Z + W ' Fine pomeriggio
S = 0 ' inizio notte
For Each Q In Range(Cells(4, col), Cells(11, col))
If Right(Q.Text, 1) = "N" Or Left(Q.Text, 1) = "N" Then S = S + 1
Next
R = 0
For Each F In Range(Cells(17, col), Cells(36, col))
If Right(F.Text, 1) = "N" Or Left(F.Text, 1) = "N" Then R = R + 1
Next
Cells(44, col) = S + R
Next
Application.Run "Prototipo.xlsm!A"
Application.Run "Prototipo.xlsm!controllanotte"
End Sub
|
'On Error Resume Next If ActiveCell.Offset(0, 1) = "N" Then MsgBox " Attenzione il giorno seguente è una Notte " Else If ActiveCell.Offset(1, -6) = "N" Then MsgBox " Attenzione il giorno seguente è una Notte " Else If ActiveCell.Offset(0, -1) = "N" Then MsgBox " Attenzione il giorno seguente è una Notte " End If End If End If 'Resume |
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Target, Range("C4:I36")) Is Nothing Then 'controlla il range
Dim X As Long, Y As Long
X = Target.Offset(0, 0).Row ' successiva nella riga a destra Target.Offset(0, 1)ma sopra sara Range("C4:H36")
Y = Target.Offset(0, 0).Column ' successiva nella riga sotto Target.Offset(1, 0)ma sopra sara Range("C4:I35")
If Cells(X, Y) = "N" Then
MsgBox " Attenzione il giorno seguente è una Notte "
ElseIf Cells(X, Y) = "M" Then
MsgBox " Attenzione il giorno seguente è una Mattina "
ElseIf Cells(X, Y) = "P" Then
MsgBox " Attenzione il giorno seguente è una Pomerigio "
ElseIf Cells(X, Y) = "E" Then
MsgBox " Attenzione il giorno seguente è ???"
ElseIf Cells(X, Y) = "E2" Then
MsgBox " Attenzione il giorno seguente è ??????? "
ElseIf Cells(X, Y) = "M1" Then
MsgBox " Attenzione il giorno seguente è ??????? "
'aggiungere altre opzioni
End If
End If
End Sub
Private Sub Worksheet_SelectionChange(ByVal target As Range)
If Range("A3") = "" Then Exit Sub
Dim T, G, X, Y, B, J 'Mattina
Dim S, Q, R, F 'Notte
Dim Z, K, W, A 'Pomerigio
For col = 3 To 9
For Each X In Range(Cells(4, col), Cells(36, col))
If X = "Ma" Then B = B + 1
Next
For Each X In Range(Cells(4, col), Cells(11, col))
If Right(X.Text, 1) = "M" Or Left(X.Text, 1) = "M" Then T = T + 1
If Right(X.Text, 1) = "P" Or Left(X.Text, 1) = "P" Then Z = Z + 1
If Right(X.Text, 1) = "N" Or Left(X.Text, 1) = "N" Then S = S + 1
If J = "Ma" Then B = B + 1
Next
For Each Y In Range(Cells(17, col), Cells(36, col))
If Right(Y.Text, 1) = "M" Or Left(Y.Text, 1) = "M" Then G = G + 1
If Right(Y.Text, 1) = "P" Or Left(Y.Text, 1) = "P" Then W = W + 1
If Right(Y.Text, 1) = "N" Or Left(Y.Text, 1) = "N" Then R = R + 1
Next
Cells(44, col) = S + R
Cells(45, col) = G + T - B 'Fine Mattina
Cells(46, col) = Z + W
Next
'Application.Run "Prototipo.xlsm!A"
'Application.Run "Prototipo.xlsm!controllanotte"
End Sub
|
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Target, Range("B4:I36")) Is Nothing Then 'controlla il range
Dim X As Long, Y As Long
X = Target.Offset(0, 0).Row ' successiva nella riga a destra Target.Offset(0, 1)ma sopra sara Range("C4:H36")
Y = Target.Offset(0, 0).Column ' successiva nella riga sotto Target.Offset(1, 0)ma sopra sara Range("C4:I35")
If Cells(X, Y).Offset(0, 1) = "N" Then
MsgBox " Attenzione il giorno seguente è una Notte "
ElseIf Cells(X, Y).Offset(1, -6) = "N" Then
MsgBox " Attenzione il giorno seguente è una Notte "
ElseIf Cells(X, Y).Offset(0, -1) = "N" Then
MsgBox " Attenzione il giorno seguente è una Notte "
'aggiungere altre opzioni
End If
End If
End Sub
|
If Not Intersect(Target, Range("B4:I36")) Is Nothing Then 'controlla il range
Dim X As Long, Y As Long
X = Target.Offset(0, 0).Row ' successiva nella riga a destra Target.Offset(0, 1)ma sopra sara Range("C4:H36")
Y = Target.Offset(0, 0).Column ' successiva nella riga sotto Target.Offset(1, 0)ma sopra sara Range("C4:I35")
If Cells(X, Y).Offset(0, 1) = "N" Then
MsgBox " Attenzione il giorno seguente è una Notte "
ElseIf Cells(X, 9).Offset(1, -6) = "N" Then
MsgBox " Attenzione il giorno seguente è una Notte "
ElseIf Cells(X, Y).Offset(0, -1) = "N" Then
MsgBox " Attenzione il giorno prima è una Notte "
'aggiungere altre opzioni
End If
End If |
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Target, Range("C4:I36")) Is Nothing Then 'controlla il range
Dim X As Long, Y As Long
X = Target.Offset(0, 0).Row
Y = Target.Offset(0, 0).Column
If Y < 9 And X < 36 Then
If Cells(X, Y + 1) = "N" Then
MsgBox " Attenzione il giorno seguente è una Notte "
End If
ElseIf Y = 9 And X < 36 Then
If Cells(X + 1, 3) = "N" Then
MsgBox " Attenzione il giorno seguente è una Notte "
End If
ElseIf Y = 9 And X = 36 Then
MsgBox " Arrivati a fine archivio "
End If
End If
End Sub |
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Target, Range("C4:I36")) Is Nothing Then 'controlla il range
Dim X As Long, Y As Long
X = Target.Offset(0, 0).Row
Y = Target.Offset(0, 0).Column
If Y < 9 And X < 37 Then
If Left(Cells(X, Y + 1), 1) = "N" Then
MsgBox " Attenzione il giorno seguente è una Notte "
End If
ElseIf Y = 9 And X < 37 Then
If Left(Cells(X + 1, 3), 1) = "N" Then
MsgBox " Attenzione il giorno seguente è una Notte "
End If
ElseIf Cells(X, Y).Offset(0, -1) = "N" Then
MsgBox " Attenzione il giorno prima è una Notte "
End If
End If
End If
End Sub
|
Private Sub Worksheet_SelectionChange2(ByVal Target As Range)
If Not Intersect(Target, Range("C4:I36")) Is Nothing Then 'controlla il range
Dim X As Long, Y As Long
X = Target.Offset(0, 0).Row
Y = Target.Offset(0, 0).Column
If Y < 9 And X < 36 Then
If Cells(X, Y + 1) = "N" Then MsgBox " Attenzione il giorno seguente è una Notte "
ElseIf Cells(X, 2) = "N" Then MsgBox " Attenzione in colonna B c'è Notte "'verifica colonna B
ElseIf Y = 9 And X < 36 Then
If Cells(X + 1, 3) = "N" Then MsgBox " Attenzione il giorno seguente è una Notte "
ElseIf Y = 9 And X = 36 Then
MsgBox " non posso fare nulla, non so quale cella controllare???"
End If
End If
End Sub |
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Target, Range("C4:I36")) Is Nothing Then
X = Target.Offset(0, 0).Row ' ricavo la riga dove premuto/modificato
Y = Target.Offset(0, 0).Column ' ricavo la colonna dove premuto/modificato
If Cells(X, Y - 1) = "N" Then
MsgBox " Attenzione il giorno PRECEDENTE è una Notte "
End If
End If
End Sub |
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("C4:I36")) Is Nothing Then 'controlla il range
Dim X As Long, Y As Long
R = Target.Offset(0, 0).Row
C = Target.Offset(0, 0).Column
If Cells(R, C) = "P" Or Cells(R, C) = "P" Then
If C < 9 And R < 36 Then
If Target.Offset(0, 1) = "N" Then MsgBox " Attenzione il giorno seguente è una Notte "
ElseIf C = 9 And R < 36 Then
If Target.Offset(1, -7) = "N" Then MsgBox " Attenzione il giorno seguente è una Notte "
ElseIf C = 9 And R = 36 Then MsgBox " Fine tabella"
'aggiungere altre opzioni
End If
End If
'Qui puoi aggiungere altri criteri casomai nella Cells(R, C)scrivi qualcosa di differente da P
End If
End Sub |
