Hello,
well, Macro 1 checks if all the column headers have an expected value "string".
If not, an error MsgBox is shown.
If an error is found I want to give the user to correct the wrong column header name.
I can do it with
but this doesn't allow the user to type on the Sheet.
The best solution would be:
- Error Found
- MsgBox Shown
- Let the user type on the Sheet to correct the mistake
- The Worksheet "recognize" the Change through
Private Sub Worksheet_Change(ByVal Target As Range)
- The check routine (
) is performed again.
Sub Macro1()
Dim ArrayTitoli(13) As String
Dim Result As Integer
' Declare Array with correct column headers
ArrayTitoli(0) = "Anno Stagione"
ArrayTitoli(1) = "Tema"
ArrayTitoli(2) = "Fase di Nascita cod"
ArrayTitoli(3) = "Classe"
ArrayTitoli(4) = "Articolo"
ArrayTitoli(5) = "Colore"
ArrayTitoli(6) = "Quantità"
ArrayTitoli(7) = "0 - DA RICEVERE"
ArrayTitoli(8) = "1 - DA LANCIARE"
ArrayTitoli(9) = "2 - TAGLIO"
ArrayTitoli(10) = "3 - PREPARAZIONE"
ArrayTitoli(11) = "4 - ASSEMBLAGGIO"
ArrayTitoli(12) = "5 - RIFINITURE"
ArrayTitoli(13) = "CHIUSE"
ControllaColonne:
For i = 0 To 13
With Range("A1")
If .Offset(0, i) <> ArrayTitoli(i) Then
Result = MsgBox("Verificare che i titoli corrispondano all'estrazione corretta." _
& Chr(13) & "L'ordine corretto è il seguente:" _
& Chr(13) & "" _
& Chr(13) & "Anno Stagione" _
& Chr(13) & "Tema" _
& Chr(13) & "Fase di Nascita cod" _
& Chr(13) & "Classe" _
& Chr(13) & "Articolo" _
& Chr(13) & "Colore" _
& Chr(13) & "Quantità" _
& Chr(13) & "0 - DA RICEVERE" _
& Chr(13) & "1 - DA LANCIARE" _
& Chr(13) & "2 - TAGLIO" _
& Chr(13) & "3 - PREPARAZIONE" _
& Chr(13) & "4 - ASSEMBLAGGIO" _
& Chr(13) & "5 - RIFINITURE" _
& Chr(13) & "CHIUSE" _
& Chr(13) _
& Chr(13) & "Errore nell colonna: " & i + 1 & ".", vbCritical, "Colonne non Corrispondenti")
End If
End With
Next
' ****PROBLEM****
If Result > 0 Then
Application.Run "Sheet1.Worksheet_Change", Range("A1")
'Application.Wait (Now + TimeValue("0:00:10"))
'GoTo ControllaColonne
End If
End Sub
Thanks!
Bookmarks