Buon Giorno a tutti .
Ho creato un DB Excel che viene alimentato attraverso una UserForm1 e aggiornato mediante altra UserForm2 .
Per la UserForm2 uso una ComboBox che legge una certa colonna del DB che ha due possibili contenuti , VUOTO oppure un testo sempre uguale , e in base alla selezione le TextBox della UserForm si rienpie di conseguenza .
Vorrei che aprendo la ComboBox vengano visualizzati , e quindi siano selezionabili , le sole celle del DB che contengono il testo .
Grazie per l'attenzione e per gli eventuali suggerimenti .
Ivo
Parte del Codice :
Option Explicit
Dim Count As Integer
Dim sh As Worksheet
Private Sub UserForm_Initialize()
Set sh = ThisWorkbook.Worksheets("DataBase")
Call mCaricaComboBox
End Sub
Private Sub mCaricaComboBox()
Dim lRiga As Long
Dim lng As Long
With sh
lRiga = .Range("A" & .Rows.Count).End(xlUp).Row
For lng = 2 To lRiga
Me.ComboBox1.AddItem (.Cells(lng, 13).Value)
Next
End With
End Sub
Private Sub ComboBox1_Click()
Dim lRiga As Long
Dim lng As Long
With sh
' La riga sotto determina il numero di righe piene
lRiga = .Range("A" & .Rows.Count).End(xlUp).Row
For lng = 2 To lRiga
If CStr(.Cells(lng, 13).Value) = Me.ComboBox1.Text Then
Me.TextBox1.Text = .Cells(lng, 1).Value
Me.TextBox2.Text = .Cells(lng, 2).Value
Me.TextBox3.Text = .Cells(lng, 3).Value
Me.TextBox4.Text = .Cells(lng, 4).Value
Me.TextBox5.Text = .Cells(lng, 5).Value
Me.TextBox6.Text = .Cells(lng, 6).Value
Me.TextBox7.Text = .Cells(lng, 7).Value
Me.TextBox8.Text = .Cells(lng, 8).Value
Me.TextBox9.Text = .Cells(lng, 9).Value
Me.TextBox10.Text = .Cells(lng, 10).Value
Me.TextBox11.Text = .Cells(lng, 11).Value
Me.TextBox12.Text = .Cells(lng, 12).Value
Me.TextBox13.Text = .Cells(lng, 13).Value
Exit For
End If
Next
End With
End Sub