jrs
08-10-2022 14:39:39
Como é feito para incluir mais planilhas e combobox a serem preenchidos?
Set ws = ThisWorkbook.Worksheets("Planilha4")
Set ws = ThisWorkbook.Worksheets("Planilha5")
Set ws = ThisWorkbook.Worksheets("Planilha6")
If x = 1 Then Me.ComboBox2.AddItem c
If x = 1 Then Me.ListBox1.AddItem c
If x = 1 Then Me.ListBox2.AddItem c
Set ws = ThisWorkbook.Worksheets("Planilha4")
Set ws = ThisWorkbook.Worksheets("Planilha5")
Set ws = ThisWorkbook.Worksheets("Planilha6")
If x = 1 Then Me.ComboBox2.AddItem c
If x = 1 Then Me.ListBox1.AddItem c
If x = 1 Then Me.ListBox2.AddItem c
Código: Selecionar todos
Private Sub UserForm_Initialize()
'--------------------------'
Dim x As Long, ncell As Long
Dim Rng As Range, c As Range
Dim ws As Worksheet
Set ws = ThisWorkbook.Worksheets("Planilha3")
With ws
ncell = .Cells(.Rows.Count, "A").End(xlUp).Row
Me.ComboBox1.Clear
For y = 1 To ncell
Set c = .Cells(y, 1)
Set Rng = .Range(.Cells(2, 1), .Cells(y, 1))
x = Application.WorksheetFunction.CountIf(Rng, c)
If x = 1 Then Me.ComboBox1.AddItem c
Next y
End With
End Sub