Hello,
I have Userform where I have checkboxes. So far I had VBA code to tick checkboxes If there was countIf=2...I want to change that to tick checkboxes If whole string (text) from one cell is selected, and only a string from another is selected. Example in column E :
If E3 is "MIN1", and E4 is "07:00-19:00" - checkbox ticked !... but I want string "07:00-19:00" to be selected If string begins Like "0*" !
my code so far :
Private Sub CboDate_Change()
Dim lngRow As Long
Dim lngIndex As Long
Dim lngCol As Long
Dim lngRes As Long
Dim lngArr As Long
Dim varItem As Variant
varItem = Array("MIN1", "MIN2", "MIN3", "MIN4")
lngCol = CboDate.ListIndex + 5
lngRow = 3
With ThisWorkbook.ActiveSheet
For lngIndex = 0 To LstUsers.ListCount - 1
LstUsers.List(lngIndex, 1) = .Cells(lngRow, lngCol)
LstUsers.List(lngIndex, 2) = .Cells(lngRow + 1, lngCol)
lngRow = lngRow + 4
Next lngIndex
For lngArr = LBound(varItem) To UBound(varItem)
lngRes = WorksheetFunction.CountIf(.Range(.Cells(3, lngCol), .Cells(318, lngCol)), varItem(lngArr))
If lngRes = 2 Then
Controls("checkbox" & lngArr + 1) = True
ElseIf lngRes > 2 Then
Controls("checkbox" & lngArr + 1) = False
MsgBox "More than 2 assignments for " & varItem(lngArr) & "A", vbExclamation
Else
Controls("checkbox" & lngArr + 1) = False
End If
Next lngArr
End With
I Have attached sample worksheet, but I don't know why isn't working, I copied from mine. Can't upload mine worksheet, It's size is over this forum regulation (1.2 Mb).
Bookmarks