
Private Sub Workbook_Open()
Set dict = CreateObject("Scripting.Dictionary") '?????????
With Sheets(1)
last_row = .Cells(.Rows.Count, "D").End(xlUp).Row
rng = .Range("D2:D" & last_row)
For i = 1 To UBound(rng, 1)
dict(rng(i, 1)) = 0
Next i
v = Application.Transpose(dict.keys) '???????????
End With
Load UserForm1
With UserForm1
.ComboBox1.List = v
.Show
End With
End Sub |
With Sheets(1)
lr = .Cells(.Rows.Count, "D").End(xlUp).Row
ReDim arr(1 To lr, 1 To 3) <<<<<<<<<<<<<<
i = 1
For r = 2 To lr
If .Cells(r, "D") = pr Then
arr(i, 1) = Cells(r, "A")
arr(i, 2) = Cells(r, "B")
arr(i, 3) = Cells(r, "C")
i = i + 1
End If
Next
nmax = i - 1
End With |
Private Sub UserForm_Initialize()
Dim lng As Long
Dim col1 As Collection
Set col1 = New Collection
Set sh = ThisWorkbook.Worksheets(1)
With sh
LR = .Range("A" & .Rows.Count).End(xlUp).Row
For lng = 2 To LR
On Error Resume Next
col1.Add CStr(.Cells(lng, "A").Value), CStr(.Cells(lng, "A").Value)
If Err.Number = 0 Then
Me.ComboBox1.AddItem (.Cells(lng, "A").Value)
End If
Err.Number = 0
Next
End With
End Sub |
