Results 1 to 1 of 1

combobox - count if

Threaded View

  1. #1
    Forum Contributor
    Join Date
    02-09-2014
    Location
    Kamnik, Slovenia
    MS-Off Ver
    Excel 2010
    Posts
    693

    combobox - count if

    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).
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 1
    Last Post: 11-07-2014, 01:21 PM
  2. [SOLVED] Make combobox list options dependant on selection in another combobox within a userform
    By Vladimir_Dobvchenko in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-23-2013, 05:30 AM
  3. [SOLVED] count no of instaces occured in userform combobox
    By cfinch100 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-17-2013, 12:51 PM
  4. [SOLVED] Excel Userform: Populate other controls (i.e. textbox & combobox) based on combobox select
    By MileHigh_PhD in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-22-2013, 04:50 PM
  5. Replies: 2
    Last Post: 01-03-2012, 11:23 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1