Private Sub CommandButton2_Click()
On Error GoTo 10
Unload Me
Worksheets("Doppi").Activate
Columns("A:Z").Select
Selection.Font.Bold = False
Selection.Sort Key1:=Range("A4"), Order1:=xlAscending, Key2:=Range("B2") _
, Order2:=xlAscending, Key3:=Range("A4"), Order3:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal, DataOption2:=xlSortNormal, DataOption3:= _
xlSortNormal
Selection.Columns.AutoFit
X = 2
Do
X = X + 1
Loop Until Cells(X, 1).Value = ""
Range("A4:Z" & X - 1).Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
For colonna = 1 To 4
Cells(2, colonna).Interior.ColorIndex = 35
Next colonna
For riga = 3 To X - 1
If Cells(riga, 3).Value = Cells(riga - 1, 3).Value And Range("A" & riga - 1 & ":" & "Z" & riga - 1).Interior.ColorIndex = 35 Then
Range("A" & riga & ":" & "Z" & riga).Interior.ColorIndex = 35
ElseIf Cells(riga, 3).Value = Cells(riga - 1, 3).Value And Range("A" & riga - 1 & ":" & "Z" & riga - 1).Interior.ColorIndex = xlNone Then
Range("A" & riga & ":" & "Z" & riga).Interior.ColorIndex = xlNone
ElseIf Cells(riga, 3).Value <> Cells(riga - 1, 3).Value And Range("A" & riga - 1 & ":" & "Z" & riga - 1).Interior.ColorIndex = 35 Then
Range("A" & riga & ":" & "Z" & riga).Interior.ColorIndex = xlNone
ElseIf Cells(riga, 3).Value <> Cells(riga - 1, 3).Value And Range("A" & riga - 1 & ":" & "Z" & riga - 1).Interior.ColorIndex = xlNone Then
Range("A" & riga & ":" & "Z" & riga).Interior.ColorIndex = 35
End If
Next riga
For riga = 2 To 20
If Cells(riga, 3).Value <> Cells(riga + 1, 3).Value Then Exit For
Next riga
Range("A4:Z" & riga).Select
Selection.Interior.ColorIndex = 37
Selection.Font.Bold = True
With Selection.Font
.Name = "Comic Sans MS"
.Size = 12
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Range("A1").Select
10:
Exit Sub
End Sub
Private Sub ComboBox1_Change()
Set Uno = Worksheets("Francobolli_emessi")
Y = 2
Do
If Uno.Cells(Y, 1).Value = ComboBox1.Text Then ComboBox2.Text = Uno.Cells(Y, 2).Value
Y = Y + 1
Loop Until Worksheets("Francobolli_emessi").Cells(Y, 1) = ""
End Sub
Private Sub CommandButton3_Click()
End Sub
Private Sub ComboBox2_Change()
ComboBox1.ListRows = 40
ComboBox1.RowSource = ""
Set Uno = Worksheets("Francobolli_emessi")
Y = 2
Do
If Uno.Cells(Y, 2).Value = ComboBox2.Text Then ComboBox1.AddItem Uno.Cells(Y, 1).Value
Y = Y + 1
Loop Until Worksheets("Francobolli_emessi").Cells(Y, 1) = ""
If ComboBox2.Text = "" Then ComboBox1.RowSource = "Francobolli_emessi!b2:b" & Y - 1
End Sub
Private Sub UserForm_Activate()
Dim riga As Integer
riga = Worksheets("Dati").Cells(2, 3)
ComboBox1.RowSource = ("Francobolli_emessi!b2:b" & riga)
ComboBox2.RowSource = ("Dati!B1:B4000")
TextBox3.Text = 0
TextBox4.Text = 0
ComboBox1.Text = ""
ComboBox2.Text = ""
End Sub
'commento
|