Hi, nashle6,
change the code behind the userform to:
Dim blnNotNew As Boolean
'>>>CommandButton 'Modify'<<<
Private Sub ModifyCB_Click()
Dim rngFound As Range
Dim lngCol As Long
With Sheets("Scoring")
Set rngFound = .Range("D:D").Find(what:=EntrantCB.List(EntrantCB.ListIndex, 1))
If Not rngFound Is Nothing Then
For lngCol = 3 To 8
Cells(rngFound.Row, 2 + lngCol).Value = Controls("txtBox" & lngCol).Value
Controls("txtBox" & lngCol).Value = vbNullString
Next lngCol
EntrantCB.Clear
blnNotNew = True
ColourDrop.ListIndex = -1
End If
End With
End Sub
'>>>ComboBox 'ColourDrop'<<<
Private Sub ColourDrop_Change()
Dim lngCounter As Long
Dim lngCol As Long
Dim arr()
Dim lngArr As Long
EntrantCB.Clear
For lngCol = 3 To 8
Controls("txtbox" & lngCol).Value = vbNullString
Next lngCol
With Sheets("Scoring")
For lngCounter = 2 To .Cells(Rows.Count, "C").End(xlUp).Row
If UCase(.Cells(lngCounter, "C").Value) = UCase(ColourDrop.Value) Then
ReDim arr(lngArr, 1)
arr(lngArr, 0) = .Cells(lngCounter, "A")
arr(lngArr, 1) = .Cells(lngCounter, "D")
lngArr = lngArr + 1
End If
Next lngCounter
End With
If blnNotNew Then
Me.EntrantCB.Clear
Else
With Me.EntrantCB
.Clear
.ColumnCount = 2
.ColumnWidths = "50Pt;0Pt"
.List = arr
.ListIndex = 0
End With
End If
blnNotNew = False
End Sub
'>>>ComboBox 'EntrantCB'<<<
Private Sub EntrantCB_Change()
Dim lngCol As Long
Dim rngFound As Range
With Sheets("Scoring")
Set rngFound = .Range("A:A").Find(what:=EntrantCB.Value)
If Not rngFound Is Nothing Then
For lngCol = 3 To 8
Controls("txtbox" & lngCol).Value = .Cells(rngFound.Row, 2 + lngCol).Value
Next lngCol
End If
Set rngFound = Nothing
End With
End Sub
'>>> General <<<
Private Sub UserForm_Initialize()
Dim wbBook As Workbook
Dim wsSheet As Worksheet
Dim rnData As Range
Dim rngCell As Range
Set wbBook = ThisWorkbook
Set wsSheet = wbBook.Worksheets("Scoring")
With wsSheet
Set rnData = .Range(.Range("C2"), .Range("C" & Rows.Count).End(xlUp))
End With
With Me.ColourDrop
.Clear
For Each rngCell In rnData
If WorksheetFunction.CountIf(wsSheet.Range("C2:C" & rngCell.Row), rngCell) = 1 Then
.AddItem rngCell
End If
Next rngCell
.ListIndex = -1
End With
End Sub
Ciao,
Holger
Bookmarks