
Dim Uriga1 As Long, R As Long, C As Long, X As Long, Riga As Object, Col As Object
Private Sub UserForm_Activate()
UserForm2.ComboBox1.RowSource = "RANGE"
End Sub
Private Sub ComboBox1_change()
If UserForm2.ComboBox1.Text = "0,01-0,05" Or UserForm2.ComboBox1.Text = "0,06-0,10" Or UserForm2.ComboBox1.Text = "0,11-0,15" Or UserForm2.ComboBox1.Text = "0,16-0,20" Or UserForm2.ComboBox1.Text = "0,21-0,25" Then
ComboBox2.RowSource = "COLORE1"
ComboBox3.RowSource = "QUALITA1"
Else
' ComboBox1.Text = "0,26-0,30" Or ComboBox1.Text = "0,31-0,36" And ComboBox2 <> "" And ComboBox3 <> ""
ComboBox2.RowSource = "COLORE2"
ComboBox3.RowSource = "QUALITA2"
End If
UserForm2.TextBox2.Text = ""
If UserForm2.ComboBox1 <> "" And UserForm2.ComboBox2 <> "" And UserForm2.ComboBox3 <> "" Then
Uriga = Range("A" & Rows.Count).End(xlUp).Row
C = Rows("1:1" & Columns.Count).End(xlToRight).Column
Set Col = Range(Cells(1, 1), Cells(1, C)).Find(UserForm2.ComboBox3.Text, LookIn:=xlValues, LookAt:=xlWhole)
If Not Col Is Nothing Then
C = Col.Column 'Row
End If
Set Riga = Range(Cells(1, 1), Cells(Uriga, 1)).Find(UserForm2.ComboBox1.Text, LookIn:=xlValues, LookAt:=xlWhole)
If Not Riga Is Nothing Then
R = Riga.Row
For X = X + 1 To X + 30
If Cells(R + X, 1) <> "" Then
If Cells(R + X, 1) = UserForm2.ComboBox2.Text Then
R = R + X
Exit For
End If
End If
Next X
End If
If UserForm2.TextBox1.Value = True Then
UserForm2.TextBox2.Text = UserForm2.TextBox1.Value * Cells(R, C)
End If
End If
End Sub
Private Sub ComboBox2_Change()
Call Change
End Sub
Private Sub ComboBox3_Change()
Call Change
End Sub
Private Sub TextBox1_Change()
Call Change
End Sub
Private Sub Change()
UserForm2.TextBox2.Text = ""
If UserForm2.ComboBox1 <> "" And UserForm2.ComboBox2 <> "" And UserForm2.ComboBox3 <> "" Then
Uriga = Range("A" & Rows.Count).End(xlUp).Row
C = Rows("1:1" & Columns.Count).End(xlToRight).Column
Set Col = Range(Cells(1, 1), Cells(1, C)).Find(UserForm2.ComboBox3.Text, LookIn:=xlValues, LookAt:=xlWhole)
If Not Col Is Nothing Then
C = Col.Column 'Row
End If
Set Riga = Range(Cells(1, 1), Cells(Uriga, 1)).Find(UserForm2.ComboBox1.Text, LookIn:=xlValues, LookAt:=xlWhole)
If Not Riga Is Nothing Then
R = Riga.Row
For X = X + 1 To X + 30
If Cells(R + X, 1) <> "" Then
If Cells(R + X, 1) = UserForm2.ComboBox2.Text Then
R = R + X
Exit For
End If
End If
Next X
End If
If UserForm2.TextBox1.Value = True Then
UserForm2.TextBox2.Text = UserForm2.TextBox1.Value * Cells(R, C)
End If
End If
End Sub
|
Dim Uriga1 As Long, R As Long, C As Long, X As Long, Riga As Object, Col As Object
Private Sub UserForm_Activate()
UserForm2.ComboBox1.RowSource = "RANGE"
End Sub
Private Sub ComboBox1_change()
If UserForm2.ComboBox1.Text = "0,01-0,05" Or UserForm2.ComboBox1.Text = "0,06-0,10" Or UserForm2.ComboBox1.Text = "0,11-0,15" Or UserForm2.ComboBox1.Text = "0,16-0,20" Or UserForm2.ComboBox1.Text = "0,21-0,25" Then
ComboBox2.RowSource = "COLORE1"
ComboBox3.RowSource = "QUALITA1"
Else
' ComboBox1.Text = "0,26-0,30" Or ComboBox1.Text = "0,31-0,36" And ComboBox2 <> "" And ComboBox3 <> ""
ComboBox2.RowSource = "COLORE2"
ComboBox3.RowSource = "QUALITA2"
End If
UserForm2.TextBox2.Text = ""
If UserForm2.ComboBox1 <> "" And UserForm2.ComboBox2 <> "" And UserForm2.ComboBox3 <> "" Then
Uriga = Range("A" & Rows.Count).End(xlUp).Row
C = Rows("1:1" & Columns.Count).End(xlToRight).Column
Set Col = Range(Cells(1, 1), Cells(1, C)).Find(UserForm2.ComboBox3.Text, LookIn:=xlValues, LookAt:=xlWhole)
If Not Col Is Nothing Then
C = Col.Column 'Row
End If
Set Riga = Range(Cells(1, 1), Cells(Uriga, 1)).Find(UserForm2.ComboBox1.Text, LookIn:=xlValues, LookAt:=xlWhole)
If Not Riga Is Nothing Then
R = Riga.Row
For X = X + 1 To X + 30
If Cells(R + X, 1) <> "" Then
If Cells(R + X, 1) = UserForm2.ComboBox2.Text Then
R = R + X
Exit For
End If
End If
Next X
End If
If UserForm2.TextBox1.Value = True Then
UserForm2.TextBox2.Text = UserForm2.TextBox1.Value * Cells(R, C)
End If
End If
End Sub
Private Sub ComboBox3_Change()
Call Change
End Sub
Private Sub TextBox1_Change()
If UserForm2.TextBox1.Value = True Then
UserForm2.TextBox2.Text = UserForm2.TextBox1.Value * Cells(R, C)
End If
End Sub
Private Sub Change()
UserForm2.TextBox2.Text = ""
If UserForm2.ComboBox1 <> "" And UserForm2.ComboBox2 <> "" And UserForm2.ComboBox3 <> "" Then
Uriga = Range("A" & Rows.Count).End(xlUp).Row
LC = Rows("1:1" & Columns.Count).End(xlToRight).Column
Set Col = Range(Cells(1, 1), Cells(1, LC)).Find(UserForm2.ComboBox3.Text, LookIn:=xlValues, LookAt:=xlWhole)
If Not Col Is Nothing Then
C = Col.Column 'Row
End If
Set Riga = Range(Cells(1, 1), Cells(Uriga, 1)).Find(UserForm2.ComboBox1.Text, LookIn:=xlValues, LookAt:=xlWhole)
If Not Riga Is Nothing Then
R = Riga.Row
For X = X + 1 To X + 30
If Cells(R + X, 1) <> "" Then
If Cells(R + X, 1) = UserForm2.ComboBox2.Text Then
R = R + X
Exit For
End If
End If
Next X
End If
End If
End Sub |
Set Col = Range(Cells(1, 1), Cells(Uriga, LC)).Find(UserForm2.ComboBox3.Text, LookIn:=xlValues, LookAt:=xlWhole) |
Private Sub ComboBox2_Change()
Call Change
End Sub |
Option Explicit
Dim Tabella As Range
Private Sub SetResult()
Me.TextBox1 = Tabella.Offset(Me.ComboBox2.ListIndex + 1, Me.ComboBox3.ListIndex + 1)
End Sub
Private Function vCombos() As Boolean
vCombos = Me.ComboBox1 <> "" And Me.ComboBox2 <> "" And Me.ComboBox3 <> ""
End Function
Private Sub ComboBox2_Change()
If vCombos Then SetResult
End Sub
Private Sub ComboBox3_Change()
If vCombos Then SetResult
End Sub
Private Sub ComboBox1_change()
Dim I As Long
Me.ComboBox2.Clear
Me.ComboBox3.Clear
Set Tabella = Foglio1.UsedRange.Columns(1).Find(Me.ComboBox1)
If Not Tabella Is Nothing Then
With Me.ComboBox2
For I = 1 To Tabella.CurrentRegion.Rows.Count - 1
.AddItem Tabella.Offset(I, 0)
Next I
End With
With Me.ComboBox3
For I = 1 To Tabella.CurrentRegion.Columns.Count - 1
.AddItem Tabella.Offset(0, I)
Next I
End With
End If
End Sub
Private Sub UserForm_Activate()
UserForm2.ComboBox1.RowSource = "RANGE"
End Sub
Private Sub UserForm_Terminate()
Set Tabella = Nothing
End Sub
|
