Ti segnalo che il codice che hai pubblicato lavorera' solo sul file che e' selezionato al momento dell'esecuzione macro.
Se vuoi sondare tutti i fogli dovrai indirizzarli uno per uno; se vuoi selezionare la cella da compilare allora dovrai selezionarla.
Se vuoi colorare in rosso una cella non compilata allora ti suggerisco di farlo tramite "Formattazione condizionale" usando la formula appropriata. Es per K4 userai la formula
- Codice: Seleziona tutto
=E($A$4>0;K4="")
La stessa formattazione puoi copiarla su Q4
Per H7 userai invece
- Codice: Seleziona tutto
=E($A$4>0;$A$5>0;H7="")
La stessa formattazione puoi copiarla su J7
E cosi' via per le altre celle. Tra l'altro questo rendera' piu' evidente all'utente gia' durante la compilazione che certe celle sono da guardare meglio.
Quindi invece che un sistema piu' carino ti propino questa bozza piu' funzionante:
- Codice: Seleziona tutto
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim Mess As String, cSh
'
Mess = "Compilare Cella!"
Application.ScreenUpdating = False
For Each cSh In Array("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", _
"17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31")
Sheets(cSh).Select
If Range("A4") > 0 Then
ccell = "K4"
If Range(ccell) = "" Then
Range(ccell).Select
MsgBox Mess
Cancel = True: GoTo Usci
End If
ccell = "Q4"
If Range(ccell) = "" Then
Range(ccell).Select
MsgBox Mess
Cancel = True: GoTo Usci
End If
If Range("A5") > 0 Then
ccell = "H7"
If Range(ccell) = "" Then
MsgBox Mess
Range(ccell).Select
Cancel = True: GoTo Usci
End If
ccell = "J7"
If Range(ccell) = "" Then
MsgBox Mess
Range(ccell).Select
Cancel = True: GoTo Usci
End If
End If
'
'tutte le altre condizioni
'tutte le altre condizioni
'tutte le altre condizioni
'
End If
Next cSh
'fine:
Usci:
Application.ScreenUpdating = True
End Sub
Le uniche migliorie riguardano il messaggio che e' standard per ogni cella in errore (infatti sono sicuro che sul foglio ci sono gia' le indicazioni di quale parametro si tratti), e la standardizzazione del blocco di controllo (If Range(ccell) = "" Then / End If) che quindi puo' essere replicato con semplice Copia /Incolla.
Certamente si potrebbe fare una struttura meno enumerativa e piu' dichiarativa, ma questo richiederebbe un livello di astrazione difficile per me da spiegare sul forum.
Ciao