enfantter
11-22-2007, 05:02 AM
Hey all,
I get a bug when i try to alter this piece of code so that instead of "A2" in rng1 there should be "A5". when i run it, the code is not able to call the userform called udvalg..
Private Sub userform_initialize()
Dim UniqueList() As String
Dim x As Long
Dim c As range
Dim Unique As Boolean
Dim y As Long
Dim Rng1 As range
Dim Rng2 As range
Dim Rng3 As range
Dim Rng4 As range
'Opgavenavn
Set Rng1 = range(Sheets("Indtastning af ny opgave").range("A2"), Sheets("Indtastning af ny opgave").range("A" & Rows.Count).End(xlUp))
y = 1
ReDim UniqueList(1 To Rng1.Rows.Count)
For Each c In Rng1
If Not c.Value = vbNullString Then
Unique = True
For x = 1 To y
If UniqueList(x) = c.Text Then
Unique = False
End If
Next
If Unique Then
y = y + 1
Me.lstopg.AddItem (c.Text)
UniqueList(y) = c.Text
End If
End If
Next
I get a bug when i try to alter this piece of code so that instead of "A2" in rng1 there should be "A5". when i run it, the code is not able to call the userform called udvalg..
Private Sub userform_initialize()
Dim UniqueList() As String
Dim x As Long
Dim c As range
Dim Unique As Boolean
Dim y As Long
Dim Rng1 As range
Dim Rng2 As range
Dim Rng3 As range
Dim Rng4 As range
'Opgavenavn
Set Rng1 = range(Sheets("Indtastning af ny opgave").range("A2"), Sheets("Indtastning af ny opgave").range("A" & Rows.Count).End(xlUp))
y = 1
ReDim UniqueList(1 To Rng1.Rows.Count)
For Each c In Rng1
If Not c.Value = vbNullString Then
Unique = True
For x = 1 To y
If UniqueList(x) = c.Text Then
Unique = False
End If
Next
If Unique Then
y = y + 1
Me.lstopg.AddItem (c.Text)
UniqueList(y) = c.Text
End If
End If
Next