Allora non è un vero database; è una grande tabella excel contenente delle formule.
Questo è l'intero codice della user form di registrazione:
Private Sub ComboBox10_AfterUpdate()
If ComboBox10.Text = "" Then
MsgBox "Campo KPI vuoto.", vbCritical, "Errore"
End If
End Sub
Private Sub ComboBox10_DropButtonClick()
Me.ComboBox10.List = Application.Transpose(Range("BT7:BV7"))
End Sub
Private Sub ComboBox11_AfterUpdate()
If ComboBox11.Text = "" Then
MsgBox "Campo Escalation Formula vuoto.", vbCritical, "Errore"
End If
End Sub
Private Sub ComboBox11_DropButtonClick()
Me.ComboBox11.List = Application.Transpose(Range("BT7:BV7"))
End Sub
Private Sub ComboBox12_AfterUpdate()
If ComboBox12.Text = "" Then
MsgBox "Campo Rebates vuoto.", vbCritical, "Errore"
End If
End Sub
Private Sub ComboBox12_DropButtonClick()
Me.ComboBox12.List = Application.Transpose(Range("BT7:BV7"))
End Sub
Private Sub ComboBox13_AfterUpdate()
If ComboBox13.Text = "" Then
MsgBox "Selezionare Valore Commodity L3.", vbCritical, "Errore"
End If
End Sub
Private Sub ComboBox13_DropButtonClick()
Me.ComboBox13.List = Application.Transpose(Range("BT8:BV8"))
End Sub
Private Sub ComboBox2_AfterUpdate()
If ComboBox2.Text = "" Then
MsgBox "Selezionare Valore Commodity L3.", vbCritical, "Errore"
End If
End Sub
Private Sub ComboBox2_DropButtonClick()
Me.ComboBox2.List = Application.Transpose(Range("BT3:EH3"))
End Sub
Private Sub ComboBox3_AfterUpdate()
If ComboBox3.Text = "" Then
MsgBox "Selezionare Contract Type.", vbCritical, "Errore"
End If
End Sub
Private Sub ComboBox3_DropButtonClick()
Me.ComboBox3.List = Application.Transpose(Range("BT4:BY4"))
End Sub
Private Sub ComboBox4_AfterUpdate()
If ComboBox4.Text = "" Then
MsgBox "Selezionare Valore Commodity L2.", vbCritical, "Errore"
End If
End Sub
Private Sub ComboBox4_DropButtonClick()
Me.ComboBox4.List = Application.Transpose(Range("BT2:CB2"))
End Sub
Private Sub ComboBox5_AfterUpdate()
If ComboBox5.Text = "" Then
MsgBox "Definire area procurement ID.", vbCritical, "Errore"
End If
End Sub
Private Sub ComboBox5_DropButtonClick()
Me.ComboBox5.List = Application.Transpose(Range("BT5:BV5"))
End Sub
Private Sub ComboBox6_AfterUpdate()
If ComboBox6.Text = "" Then
MsgBox "Campo Currency vuoto.", vbCritical, "Errore"
End If
End Sub
Private Sub ComboBox6_DropButtonClick()
Me.ComboBox6.List = Application.Transpose(Range("BT6:BW6"))
End Sub
Private Sub ComboBox7_AfterUpdate()
If ComboBox7.Text = "" Then
MsgBox "Campo Volume Committent vuoto.", vbCritical, "Errore"
End If
End Sub
Private Sub ComboBox7_DropButtonClick()
Me.ComboBox7.List = Application.Transpose(Range("BT7:BV7"))
End Sub
Private Sub ComboBox8_AfterUpdate()
If ComboBox8.Text = "" Then
MsgBox "Campo Automatic renewal clauses vuoto.", vbCritical, "Errore"
End If
End Sub
Private Sub ComboBox8_DropButtonClick()
Me.ComboBox8.List = Application.Transpose(Range("BT7:BV7"))
End Sub
Private Sub ComboBox9_AfterUpdate()
If ComboBox9.Text = "" Then
MsgBox "Campo Early Termination vuoto.", vbCritical, "Errore"
End If
End Sub
Private Sub ComboBox9_DropButtonClick()
Me.ComboBox9.List = Application.Transpose(Range("BT7:BV7"))
End Sub
Private Sub CommandButton1_Click()
Unload Me
Windows("AW IP Modulo Registrazione Contratti.xlsm").Activate
Range("A1").Select
ActiveWindow.LargeScroll ToRight:=1
Range("AB5:BH5").Select
Selection.Copy
Range("A1").Select
ActiveCell.Offset(8, 27).Range("A1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveSheet.Paste
ActiveSheet.Range("A1").Select
Application.CutCopyMode = False
ActiveWorkbook.Save
UserForm1.Show
End Sub
Private Sub CommandButton2_Click()
Unload Me
If ComboBox13.Text = "" Then
MsgBox "Selezionare valore in Campo Company.", vbCritical, "Errore"
UserForm1.Show
Exit Sub
End If
If ComboBox5.Text = "" Then
MsgBox "Definire area procurement ID.", vbCritical, "Errore"
UserForm1.Show
Exit Sub
End If
If ComboBox4.Text = "" Then
MsgBox "Selezionare Valore Commodity L2.", vbCritical, "Errore"
UserForm1.Show
Exit Sub
End If
If ComboBox2.Text = "" Then
MsgBox "Selezionare Valore Commodity L3.", vbCritical, "Errore"
UserForm1.Show
Exit Sub
End If
If Not Left(Range("AD5").Value, 1) = Left(Range("AE5").Value, 1) Then
MsgBox "La Commodity L3 deve essere della stessa famiglia della Commodity L2.", vbCritical, "Errore"
UserForm1.Show
Exit Sub
End If
If TextBox3.Text = "" Then
MsgBox "Inserire Descrizione.", vbCritical, "Errore"
UserForm1.Show
Exit Sub
End If
If TextBox28.Text = "" Then
MsgBox "Inserire Vendor Code.", vbCritical, "Errore"
UserForm1.Show
Exit Sub
End If
If TextBox26.Text = "" Then
MsgBox "Inserire Buyer Code.", vbCritical, "Errore"
UserForm1.Show
Exit Sub
End If
If TextBox7.Text = "" Then
MsgBox "Inserire SAP Contract Number.", vbCritical, "Errore"
UserForm1.Show
Exit Sub
End If
If ComboBox3.Text = "" Then
MsgBox "Selezionare Contract Type.", vbCritical, "Errore"
UserForm1.Show
Exit Sub
End If
If TextBox8.Text = "" Then
MsgBox "Inserire Breve Descrizione.", vbCritical, "Errore"
UserForm1.Show
Exit Sub
End If
If TextBox30.Text = "" Then
MsgBox "Inserire Data in formato dd/mm/yyyy in Date of Creation.)", vbCritical, "Errore"
UserForm1.Show
Exit Sub
End If
If TextBox11.Text = "" Then
MsgBox "Inserire Data in formato dd/mm/yyyy in Validity - Start Data.)", vbCritical, "Errore"
UserForm1.Show
Exit Sub
End If
If TextBox12.Text = "" Then
MsgBox "Inserire Data in formato dd/mm/yyyy in Validity - End Data.)", vbCritical, "Errore"
UserForm1.Show
Exit Sub
End If
If TextBox13.Text = "" Then
MsgBox "Inserire valore numerico in Contract Value.", vbCritical, "Errore"
UserForm1.Show
Exit Sub
End If
If ComboBox6.Text = "" Then
MsgBox "Campo Currency vuoto.", vbCritical, "Errore"
UserForm1.Show
Exit Sub
End If
If ComboBox7.Text = "" Then
MsgBox "Campo Volume Committent vuoto.", vbCritical, "Errore"
UserForm1.Show
Exit Sub
End If
If ComboBox11.Text = "" Then
MsgBox "Campo Escalation Formula vuoto.", vbCritical, "Errore"
UserForm1.Show
Exit Sub
End If
If ComboBox12.Text = "" Then
MsgBox "Campo Rebates vuoto.", vbCritical, "Errore"
UserForm1.Show
Exit Sub
End If
If ComboBox8.Text = "" Then
MsgBox "Campo Automatic renewal clauses vuoto.", vbCritical, "Errore"
UserForm1.Show
Exit Sub
End If
If ComboBox9.Text = "" Then
MsgBox "Campo Early Termination vuoto.", vbCritical, "Errore"
UserForm1.Show
Exit Sub
End If
If ComboBox10.Text = "" Then
MsgBox "Campo KPI vuoto.", vbCritical, "Errore"
UserForm1.Show
Else
Dim fso
Dim fol As String
fol = "C:\Users\giuseppe.divico\Desktop\Contratti" & Range("AD5").Value & "" & Range("AE5").Value & "" & Range("AG5").Value & "_" & Range("AH5").Value
Set fso = CreateObject("Scripting.FileSystemObject")
If Not fso.FolderExists(fol) Then
fso.CreateFolder (fol)
End If
Dim fsa
Dim fal As String
fal = "C:\Users\giuseppe.divico\Desktop\Contratti" & Range("AD5").Value & "" & Range("AE5").Value & "" & Range("AG5").Value & "_" & Range("AH5").Value & "" & Range("AM5").Value & "_" & Range("AN5").Value
Set fsa = CreateObject("Scripting.FileSystemObject")
If Not fsa.FolderExists(fal) Then
fsa.CreateFolder (fal)
Else
MsgBox "Cartella già esistente. Modificare SAP Number o utilizzare un'altra descrizione breve.", vbCritical, "Errore"
UserForm1.Show
End If
If IsFileOpen("C:\Users\giuseppe.divico\Desktop\AW IP Contract Repository.xlsx") Then
MsgBox "Dati registrati con successo.", vbInformation, "Registrazione contratto"
Windows("AW IP Modulo Registrazione Contratti.xlsm").Activate
Range("A1").Select
ActiveWindow.LargeScroll ToRight:=1
Range("AB5:BI5").Select
Selection.Copy
Windows("AW IP Contract Repository.xlsx").Activate
Range("A1").Select
ActiveCell.Offset(1, 1).Range("A1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveSheet.Paste
ActiveSheet.Range("A1").Select
Application.CutCopyMode = False
ActiveWorkbook.Save
Windows("AW IP Modulo Registrazione Contratti.xlsm").Activate
Range("A1").Select
ActiveWindow.LargeScroll ToRight:=1
Range("AB5:AG5,AI5,AK5:AS5,AU5:BG5").Select
Selection.ClearContents
Range("A1").Select
Else
MsgBox "Dati registrati con successo.", vbInformation, "Registrazione contratto"
Workbooks.Open filename:="C:\Users\giuseppe.divico\Desktop\AW IP Contract Repository.xlsx"
Windows("AW IP Modulo Registrazione Contratti.xlsm").Activate
Range("A1").Select
ActiveWindow.LargeScroll ToRight:=1
Range("AB5:BI5").Select
Selection.Copy
Windows("AW IP Contract Repository.xlsx").Activate
Range("A1").Select
ActiveCell.Offset(1, 1).Range("A1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveSheet.Paste
ActiveSheet.Range("A1").Select
Application.CutCopyMode = False
ActiveWorkbook.Save
Windows("AW IP Modulo Registrazione Contratti.xlsm").Activate
Range("A1").Select
ActiveWindow.LargeScroll ToRight:=1
Range("AB5:AG5,AI5,AK5:AS5,AU5:BG5").Select
Selection.ClearContents
Range("A1").Select
End If
End If
End Sub
Private Sub CommandButton3_Click()
Unload Me
Range("A1").Select
ActiveWindow.LargeScroll ToRight:=1
Range("AB5:AG5,AI5,AK5:AS5,AU5:BF5,BI5").Select
Selection.ClearContents
Range("A1").Select
ActiveWindow.LargeScroll ToRight:=1
Range("AB13:AG40, AI13, AK13:AS40, AU13:BF40, BH13:BI40").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.ClearContents
Range("A1").Select
End Sub
Private Sub CommandButton4_Click()
UserForm4.Show
End Sub
Private Sub Label1_Click()
End Sub
Private Sub TextBox1_AfterUpdate()
If TextBox1.Text = "" Then
MsgBox "Digitare Valore in Campo Company.", vbCritical, "Errore"
TextBox1.SetFocus
End If
End Sub
Private Sub Label26_Click()
End Sub
Private Sub TextBox11_AfterUpdate()
If Not IsDate(TextBox11.Text) Then
MsgBox "Inserire Data in formato dd/mm/yyyy in Validity - Start Data.)", vbCritical, "Errore"
End If
End Sub
Private Sub TextBox12_AfterUpdate()
If Not IsDate(TextBox12.Text) Then
MsgBox "Inserire Data in formato dd/mm/yyyy in Validity - End Data.)", vbCritical, "Errore"
End If
End Sub
Private Sub TextBox13_AfterUpdate()
If Not IsNumeric(TextBox13.Text) Then
MsgBox "Inserire valore numerico in Contract Value.", vbCritical, "Errore"
End If
End Sub
Private Sub TextBox26_AfterUpdate()
If TextBox26.Text = "" Then
MsgBox "Inserire Buyer Code.", vbCritical, "Errore"
UserForm1.Show
TextBox26.SetFocus
End If
End Sub
Private Sub TextBox28_AfterUpdate()
If TextBox28.Text = "" Then
MsgBox "Inserire Vendor Code.", vbCritical, "Errore"
ElseIf InStr(TextBox28.Text, "") Then
MsgBox "In Brief Description non è permesso l'inserimento di /:*<>|""", vbCritical, "Errore"
Me.TextBox28.Text = Mid(Me.TextBox28.Text, 1, Len(Me.TextBox8.Text) - 1)
ElseIf InStr(TextBox28.Text, "/") Then
MsgBox "In Brief Description non è permesso l'inserimento di /:*<>|""", vbCritical, "Errore"
Me.TextBox28.Text = Mid(Me.TextBox28.Text, 1, Len(Me.TextBox8.Text) - 1)
ElseIf InStr(TextBox28.Text, ":") Then
MsgBox "In Brief Description non è permesso l'inserimento di /:*<>|""", vbCritical, "Errore"
Me.TextBox28.Text = Mid(Me.TextBox28.Text, 1, Len(Me.TextBox8.Text) - 1)
ElseIf InStr(TextBox28.Text, "*") Then
MsgBox "In Brief Description non è permesso l'inserimento di /:*<>|""", vbCritical, "Errore"
Me.TextBox28.Text = Mid(Me.TextBox28.Text, 1, Len(Me.TextBox8.Text) - 1)
ElseIf InStr(TextBox28.Text, "<") Then
MsgBox "In Brief Description non è permesso l'inserimento di /:*<>|""", vbCritical, "Errore"
Me.TextBox28.Text = Mid(Me.TextBox28.Text, 1, Len(Me.TextBox8.Text) - 1)
ElseIf InStr(TextBox28.Text, ">") Then
MsgBox "In Brief Description non è permesso l'inserimento di /:*<>|""", vbCritical, "Errore"
Me.TextBox28.Text = Mid(Me.TextBox28.Text, 1, Len(Me.TextBox8.Text) - 1)
ElseIf InStr(TextBox28.Text, "|") Then
MsgBox "In Brief Description non è permesso l'inserimento di /:*<>|""", vbCritical, "Errore"
Me.TextBox28.Text = Mid(Me.TextBox28.Text, 1, Len(Me.TextBox8.Text) - 1)
ElseIf InStr(TextBox28.Text, Range("AB3").Value) Then
MsgBox "In Brief Description non è permesso l'inserimento di /:*<>|""", vbCritical, "Errore"
Me.TextBox28.Text = Mid(Me.TextBox28.Text, 1, Len(Me.TextBox8.Text) - 1)
End If
End Sub
Private Sub TextBox3_AfterUpdate()
If TextBox3.Text = "" Then
MsgBox "Inserire Descrizione.", vbCritical, "Errore"
End If
End Sub
Private Sub TextBox30_AfterUpdate()
If Not IsDate(TextBox30.Text) Then
MsgBox "Inserire Data in formato dd/mm/yyyy in Date of Creation.)", vbCritical, "Errore"
End If
End Sub
Private Sub TextBox7_AfterUpdate()
If TextBox7.Text = "" Then
MsgBox "Inserire SAP Contract Number.", vbCritical, "Errore"
TextBox7.SetFocus
End If
If InStr(TextBox7.Text, "/") Then
MsgBox "In SAP number non è permesso l'inserimento di /:*<>|""", vbCritical, "Errore"
Me.TextBox7.Text = Mid(Me.TextBox7.Text, 1, Len(Me.TextBox7.Text) - 1)
ElseIf InStr(TextBox7.Text, "") Then
MsgBox "In SAP number non è permesso l'inserimento di /:*<>|""", vbCritical, "Errore"
Me.TextBox7.Text = Mid(Me.TextBox7.Text, 1, Len(Me.TextBox7.Text) - 1)
ElseIf InStr(TextBox7.Text, "|") Then
MsgBox "In SAP number non è permesso l'inserimento di /:*<>|""", vbCritical, "Errore"
Me.TextBox7.Text = Mid(Me.TextBox7.Text, 1, Len(Me.TextBox7.Text) - 1)
ElseIf InStr(TextBox7.Text, Range("AB3").Value) Then
MsgBox "In SAP number non è permesso l'inserimento di /:*<>|""", vbCritical, "Errore"
Me.TextBox7.Text = Mid(Me.TextBox7.Text, 1, Len(Me.TextBox7.Text) - 1)
ElseIf InStr(TextBox7.Text, "*") Then
MsgBox "In SAP number non è permesso l'inserimento di /:*<>|""", vbCritical, "Errore"
Me.TextBox7.Text = Mid(Me.TextBox7.Text, 1, Len(Me.TextBox7.Text) - 1)
ElseIf InStr(TextBox7.Text, "<") Then
MsgBox "In SAP number non è permesso l'inserimento di /:*<>|""", vbCritical, "Errore"
Me.TextBox7.Text = Mid(Me.TextBox7.Text, 1, Len(Me.TextBox7.Text) - 1)
ElseIf InStr(TextBox7.Text, ">") Then
MsgBox "In SAP number non è permesso l'inserimento di /:*<>|""", vbCritical, "Errore"
Me.TextBox7.Text = Mid(Me.TextBox7.Text, 1, Len(Me.TextBox7.Text) - 1)
ElseIf InStr(TextBox7.Text, ":") Then
MsgBox "In SAP number non è permesso l'inserimento di /:*<>|""", vbCritical, "Errore"
Me.TextBox7.Text = Mid(Me.TextBox7.Text, 1, Len(Me.TextBox7.Text) - 1)
End If
End Sub
Private Sub TextBox8_AfterUpdate()
If TextBox8.Text = "" Then
MsgBox "Inserire Breve Descrizione.", vbCritical, "Errore"
Exit Sub
ElseIf InStr(TextBox8.Text, "") Then
MsgBox "In Brief Description non è permesso l'inserimento di /:*<>|""", vbCritical, "Errore"
TextBox8.Text = Replace(TextBox8.Text, "", "")
Exit Sub
ElseIf InStr(TextBox8.Text, "/") Then
MsgBox "In Brief Description non è permesso l'inserimento di /:*<>|""", vbCritical, "Errore"
Me.TextBox8.Text = Mid(Me.TextBox8.Text, 1, Len(Me.TextBox8.Text) - 1)
ElseIf InStr(TextBox8.Text, ":") Then
MsgBox "In Brief Description non è permesso l'inserimento di /:*<>|""", vbCritical, "Errore"
Me.TextBox8.Text = Mid(Me.TextBox8.Text, 1, Len(Me.TextBox8.Text) - 1)
ElseIf InStr(TextBox8.Text, "*") Then
MsgBox "In Brief Description non è permesso l'inserimento di /:*<>|""", vbCritical, "Errore"
Me.TextBox8.Text = Mid(Me.TextBox8.Text, 1, Len(Me.TextBox8.Text) - 1)
ElseIf InStr(TextBox8.Text, "<") Then
MsgBox "In Brief Description non è permesso l'inserimento di /:*<>|""", vbCritical, "Errore"
Me.TextBox8.Text = Mid(Me.TextBox8.Text, 1, Len(Me.TextBox8.Text) - 1)
ElseIf InStr(TextBox8.Text, ">") Then
MsgBox "In Brief Description non è permesso l'inserimento di /:*<>|""", vbCritical, "Errore"
Me.TextBox8.Text = Mid(Me.TextBox8.Text, 1, Len(Me.TextBox8.Text) - 1)
ElseIf InStr(TextBox8.Text, "|") Then
MsgBox "In Brief Description non è permesso l'inserimento di /:*<>|""", vbCritical, "Errore"
Me.TextBox8.Text = Mid(Me.TextBox8.Text, 1, Len(Me.TextBox8.Text) - 1)
ElseIf InStr(TextBox8.Text, Range("AB3").Value) Then
MsgBox "In Brief Description non è permesso l'inserimento di /:*<>|""", vbCritical, "Errore"
Me.TextBox8.Text = Mid(Me.TextBox8.Text, 1, Len(Me.TextBox8.Text) - 1)
End If
End Sub
Private Sub TextBox9_Change()
End Sub
Private Sub UserForm_Click()
End Sub