
Private Sub CommandButton1_Click()
Dim N1 As String, n2 As String, n3 As String
Dim N4 As String, n5 As Integer
Dim Ro As Integer
Set sha = Worksheets("archivio")
Application.ScreenUpdating = False
On Error Resume Next
N1 = TextBox1.Text
n2 = TextBox2.Text
n3 = ComboBox1.Value
N4 = ComboBox2.Value
n5 = ComboBox4.Value
Ro = 2
Set shr = Worksheets("ricerca")
shr.Activate
shr.Range("A2:V3000").ClearContents
If n3 = "" Then
MsgBox ("ATTENZIONE CAMPO UFFICIO OBBLIGATORIO"), vbCritical
Exit Sub
End If
If N1 <> "" And n2 <> "" Then
MsgBox ("ATTENZIONE SCEGLIRE SOLO UN NOME")
Exit Sub
End If
.........................................................................................
If N1 <> "" Or n2 <> "" And N4 <> "" And n5 <> "" Then 'primo codice = uff + nc1 o nc2 + ind + zona
For Each c In sha.Range("g:g")
If c.Value = "" Then Exit For
If c.Value = n3 And c.Offset(, -2) = N1 And c.Offset(, 1) = N4 And c.Offset(, 4) = n5 Then
Range(c.Offset(0, -6), c.Offset(0, 16)).Copy
shr.Cells(Ro, 1).Select
Selection.PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
Ro = Ro + 1
End If
Next c
For Each c In sha.Range("g:g")
If c.Value = "" Then Exit For
If c.Value = n3 And c.Offset(, -1) = n2 And c.Offset(, 1) = N4 And c.Offset(, 4) = n5 Then
Range(c.Offset(0, -6), c.Offset(0, 16)).Copy
shr.Cells(Ro, 1).Select
Selection.PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
Ro = Ro + 1
End If
Next c
End If
.....................................................................................................
If N1 <> "" Or n2 <> "" And N4 <> "" And n5 = "" Then 'secondo codice = uff + nc1 o nc2 + ind
For Each c In sha.Range("g:g")
If c.Value = "" Then Exit For
If c.Value = n3 And c.Offset(, -2) = N1 And c.Offset(, 1) = N4 Then
Range(c.Offset(0, -6), c.Offset(0, 16)).Copy
shr.Cells(Ro, 1).Select
Selection.PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
Ro = Ro + 1
End If
Next c
For Each c In sha.Range("g:g")
If c.Value = "" Then Exit For
If c.Value = n3 And c.Offset(, -1) = n2 And c.Offset(, 1) = N4 Then
Range(c.Offset(0, -6), c.Offset(0, 16)).Copy
shr.Cells(Ro, 1).Select
Selection.PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
Ro = Ro + 1
End If
Next c
End If
....................................................................................
If N1 <> "" Or n2 <> "" And N4 = "" And n5 <> "" Then 'terzo codice: uff + nc1 o nc2 + zona
For Each c In sha.Range("g:g")
If c.Value = "" Then Exit For
If c.Value = n3 And c.Offset(, -2) = N1 And c.Offset(, 4) = n5 Then
Range(c.Offset(0, -6), c.Offset(0, 16)).Copy
shr.Cells(Ro, 1).Select
Selection.PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
Ro = Ro + 1
End If
Next c
For Each c In sha.Range("g:g")
If c.Value = "" Then Exit For
If c.Value = n3 And c.Offset(, -1) = n2 And c.Offset(, 4) = n5 Then
Range(c.Offset(0, -6), c.Offset(0, 16)).Copy
shr.Cells(Ro, 1).Select
Selection.PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
Ro = Ro + 1
End If
Next c
End If
................................................................................
If N1 <> "" Or n2 <> "" And N4 = "" And n5 = "" Then 'quarto codice = uff + nc1 o nc2
For Each c In sha.Range("g:g")
If c.Value = "" Then Exit For
If c.Value = n3 And c.Offset(, -2) = N1 Then
Range(c.Offset(0, -6), c.Offset(0, 16)).Copy
shr.Cells(Ro, 1).Select
Selection.PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
Ro = Ro + 1
End If
Next c
For Each c In sha.Range("g:g")
If c.Value = "" Then Exit For
If c.Value = n3 And c.Offset(, -1) = n2 Then
Range(c.Offset(0, -6), c.Offset(0, 16)).Copy
shr.Cells(Ro, 1).Select
Selection.PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
Ro = Ro + 1
End If
Next c
End If
............................................................................
If N1 = "" And n2 = "" And N4 <> "" And n5 <> "" Then 'quinto codice: uff + ind + zona
For Each c In sha.Range("g:g")
If c.Value = "" Then Exit For
If c.Value = n3 And c.Offset(, 1) = N4 And c.Offset(, 4) = n5 Then
Range(c.Offset(0, -6), c.Offset(0, 16)).Copy
shr.Cells(Ro, 1).Select
Selection.PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
Ro = Ro + 1
End If
Next c
End If
..........................................................................
If N1 = "" And n2 = "" And N4 <> "" And n5 = "" Then 'sesto codice: uff + ind
For Each c In sha.Range("g:g")
If c.Value = "" Then Exit For
If c.Value = n3 And c.Offset(, 1) = N4 Then
Range(c.Offset(0, -6), c.Offset(0, 16)).Copy
shr.Cells(Ro, 1).Select
Selection.PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
Ro = Ro + 1
End If
Next c
End If
...............................................................................
If N1 = "" And n2 = "" And N4 = "" And n5 <> "" Then 'settimo codice: uff + zona
For Each c In sha.Range("g:g")
If c.Value = "" Then Exit For
If c.Value = n3 And c.Offset(, 4) = n5 Then
Range(c.Offset(0, -6), c.Offset(0, 16)).Copy
shr.Cells(Ro, 1).Select
Selection.PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
Ro = Ro + 1
End If
Next c
End If
.............................................................................
If N1 = "" And n2 = "" And N4 = "" And n5 = "" Then ' ottavo codice: solo uff
For Each c In sha.Range("g:g")
If c.Value = "" Then Exit For
If c.Value = n3 Then
Range(c.Offset(0, -6), c.Offset(0, 16)).Copy
shr.Cells(Ro, 1).Select
Selection.PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
Ro = Ro + 1
End If
Next c
End If
.............................................................................
If shr.Range("a2") <> "" Then
MsgBox "Ricerca ok" & vbLf & "scegli il numero del reclamo o apri pagina ricerca"
ComboBox3.RowSource = "ricerca!a2:a1500"
Exit Sub
Else
Dim risp As Integer
risp = MsgBox("Nessun record trovato" & vbLf & "inserire parametri diversi o in meno")
shr.Activate
shr.Range("A2:V3000").ClearContents
End If
End Sub |
Private Sub CommandButton1_Click()
Dim N1 As String, n2 As String, n3 As String
Dim N4 As String, n5 As String, n6 As String
Dim Ro As Integer
Set shr = Worksheets("ricerca")
Set sha = Worksheets("archivio")
Application.ScreenUpdating = False
On Error Resume Next
N1 = TextBox1.Text
n2 = TextBox2.Text
n3 = ComboBox1.Value
N4 = ComboBox2.Value
n5 = ComboBox4.Value
Ro = 2
shr.Activate
shr.Range("A2:V3000").ClearContents
If n3 = "" Then
MsgBox ("ATTENZIONE CAMPO UFFICIO OBBLIGATORIO"), vbCritical
Exit Sub
End If
'''''''''
If N1 <> "" And n2 <> "" Then
MsgBox ("ATTENZIONE SCEGLIRE SOLO UN NOME")
Exit Sub
End If
If N1 <> "" Or n2 <> "" And N4 <> "" And n5 <> "" Then 'uff + nc1 o nc2 + ind + zona
For Each c In sha.Range("g:g")
If c.Value = "" Then Exit For
If c.Value = n3 And c.Offset(, -2) = N1 And c.Offset(, 1) = N4 And c.Offset(, 4) = n5 Then
Range(c.Offset(0, -6), c.Offset(0, 15)).Copy
shr.Cells(Ro, 1).Select
Selection.PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
Ro = Ro + 1
End If
Next c
For Each c In sha.Range("g:g")
If c.Value = "" Then Exit For
If c.Value = n3 And c.Offset(, -1) = n2 And c.Offset(, 1) = N4 And c.Offset(, 4) = n5 Then
Range(c.Offset(0, -6), c.Offset(0, 15)).Copy
shr.Cells(Ro, 1).Select
Selection.PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
Ro = Ro + 1
End If
Next c
GoTo 100
End If
10:
If N1 <> "" Or n2 <> "" And N4 <> "" And n5 = "" Then 'uff + nc1 o nc2 + ind
For Each c In sha.Range("g:g")
If c.Value = "" Then Exit For
If c.Value = n3 And c.Offset(, -2) = N1 And c.Offset(, 1) = N4 Then
Range(c.Offset(0, -6), c.Offset(0, 15)).Copy
shr.Cells(Ro, 1).Select
Selection.PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
Ro = Ro + 1
End If
Next c
For Each c In sha.Range("g:g")
If c.Value = "" Then Exit For
If c.Value = n3 And c.Offset(, -1) = n2 And c.Offset(, 1) = N4 Then
Range(c.Offset(0, -6), c.Offset(0, 15)).Copy
shr.Cells(Ro, 1).Select
Selection.PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
Ro = Ro + 1
End If
Next c
GoTo 110
End If
20:
If N1 <> "" Or n2 <> "" And N4 = "" And n5 <> "" Then 'uff + nc1 o nc2 + zona
For Each c In sha.Range("g:g")
If c.Value = "" Then Exit For
If c.Value = n3 And c.Offset(, -2) = N1 And c.Offset(, 4) = n5 Then
Range(c.Offset(0, -6), c.Offset(0, 15)).Copy
shr.Cells(Ro, 1).Select
Selection.PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
Ro = Ro + 1
End If
Next c
For Each c In sha.Range("g:g")
If c.Value = "" Then Exit For
If c.Value = n3 And c.Offset(, -1) = n2 And c.Offset(, 4) = n5 Then
Range(c.Offset(0, -6), c.Offset(0, 15)).Copy
shr.Cells(Ro, 1).Select
Selection.PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
Ro = Ro + 1
End If
Next c
GoTo 120
End If
30:
If N1 <> "" Or n2 <> "" And N4 = "" And n5 = "" Then 'uff + nc1 o nc2
For Each c In sha.Range("g:g")
If c.Value = "" Then Exit For
If c.Value = n3 And c.Offset(, -2) = N1 Then
Range(c.Offset(0, -6), c.Offset(0, 15)).Copy
shr.Cells(Ro, 1).Select
Selection.PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
Ro = Ro + 1
End If
Next c
For Each c In sha.Range("g:g")
If c.Value = "" Then Exit For
If c.Value = n3 And c.Offset(, -1) = n2 Then
Range(c.Offset(0, -6), c.Offset(0, 15)).Copy
shr.Cells(Ro, 1).Select
Selection.PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
Ro = Ro + 1
End If
Next c
GoTo 130
End If
40:
If N1 = "" And n2 = "" And N4 <> "" And n5 <> "" Then 'uff + ind + zona
For Each c In sha.Range("g:g")
If c.Value = "" Then Exit For
If c.Value = n3 And c.Offset(, 1) = N4 And c.Offset(, 4) = n5 Then
Range(c.Offset(0, -6), c.Offset(0, 15)).Copy
shr.Cells(Ro, 1).Select
Selection.PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
Ro = Ro + 1
End If
Next c
GoTo 140
End If
50:
If N1 = "" And n2 = "" And N4 <> "" And n5 = "" Then 'uff + ind
For Each c In sha.Range("g:g")
If c.Value = "" Then Exit For
If c.Value = n3 And c.Offset(, 1) = N4 Then
Range(c.Offset(0, -6), c.Offset(0, 15)).Copy
shr.Cells(Ro, 1).Select
Selection.PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
Ro = Ro + 1
End If
Next c
GoTo 150
End If
60:
If N1 = "" And n2 = "" And N4 = "" And n5 <> "" Then 'uff + zona
For Each c In sha.Range("g:g")
If c.Value = "" Then Exit For
If c.Value = n3 And c.Offset(, 4) = n5 Then
Range(c.Offset(0, -6), c.Offset(0, 15)).Copy
shr.Cells(Ro, 1).Select
Selection.PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
Ro = Ro + 1
End If
Next c
GoTo 160
End If
70:
If N1 = "" And n2 = "" And N4 = "" And n5 = "" Then
For Each c In sha.Range("g:g")
If c.Value = "" Then Exit For
If c.Value = n3 Then
Range(c.Offset(0, -6), c.Offset(0, 15)).Copy
shr.Cells(Ro, 1).Select
Selection.PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
Ro = Ro + 1
End If
Next c
GoTo 170
End If
100:
If shr.Range("a2") <> "" Then
MsgBox "Ricerca ok" & vbLf & "scegli il numero del reclamo o apri pagina ricerca"
ComboBox3.RowSource = "ricerca!a2:a1500"
Exit Sub
Else
GoTo 10
End If
110:
If shr.Range("a2") <> "" Then
MsgBox "Ricerca ok" & vbLf & "scegli il numero del reclamo o apri pagina ricerca"
ComboBox3.RowSource = "ricerca!a2:a1500"
Exit Sub
Else
GoTo 20
End If
120:
If shr.Range("a2") <> "" Then
MsgBox "Ricerca ok" & vbLf & "scegli il numero del reclamo o apri pagina ricerca"
ComboBox3.RowSource = "ricerca!a2:a1500"
Exit Sub
Else
GoTo 30
End If
130:
If shr.Range("a2") <> "" Then
MsgBox "Ricerca ok" & vbLf & "scegli il numero del reclamo o apri pagina ricerca"
ComboBox3.RowSource = "ricerca!a2:a1500"
Exit Sub
Else
GoTo 40
End If
140:
If shr.Range("a2") <> "" Then
MsgBox "Ricerca ok" & vbLf & "scegli il numero del reclamo o apri pagina ricerca"
ComboBox3.RowSource = "ricerca!a2:a1500"
Exit Sub
Else
GoTo 50
End If
150:
If shr.Range("a2") <> "" Then
MsgBox "Ricerca ok" & vbLf & "scegli il numero del reclamo o apri pagina ricerca"
ComboBox3.RowSource = "ricerca!a2:a1500"
Exit Sub
Else
GoTo 60
End If
160:
If shr.Range("a2") <> "" Then
MsgBox "Ricerca ok" & vbLf & "scegli il numero del reclamo o apri pagina ricerca"
ComboBox3.RowSource = "ricerca!a2:a1500"
Exit Sub
Else
GoTo 70
End If
170:
If shr.Range("a2") <> "" Then
MsgBox "Ricerca ok" & vbLf & "scegli il numero del reclamo o apri pagina ricerca"
ComboBox3.RowSource = "ricerca!a2:a1500"
Exit Sub
Else
Dim risp As Integer
risp = MsgBox("Nessun record trovato" & vbLf & "inserire parametri diversi o in meno")
End If
End Sub |
