+ Reply to Thread
Results 1 to 2 of 2

Tick Listbox options based on Cell Values

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    12-30-2012
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    103

    Tick Listbox options based on Cell Values

    Hello friends,

    I am seeking VBA to tick the corresponding boxes in a ListBox based on Cell values on another sheet. So basically in the attached example, the outcome would be that the below would all be ticked.

    Other
    Test 1
    Test 2
    Card Payment

    I have attached an example workbook.


    Any assistance would be much appreciated.

    Thanks
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Tick Listbox options based on Cell Values

    Try this code
    Sub Select_ListBox_Items()
        Dim ws As Worksheet, obj As Object, c As Range, m As Long, r As Long
    
        Set ws = ThisWorkbook.Worksheets("Lists")
        Set obj = ThisWorkbook.Worksheets("ListBox").ListBox21
        m = ws.Cells(Rows.Count, "CS").End(xlUp).Row
    
        With obj
            For r = 0 To .ListCount - 1
                .Selected(r) = False
            Next r
        End With
    
        For Each c In ws.Range("CS4:CS" & m)
            If c.Value <> "" Then
                With obj
                    For r = 0 To .ListCount - 1
                        If c.Value = .List(r) Then .Selected(r) = True: Exit For
                    Next r
                End With
            End If
        Next c
    End Sub
    < ----- Please click the little star * next to add reputation if my post helps you
    Visit Forum : From Here

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Show unique values in listbox and activate related cell if i select value in Listbox
    By HaroonSid in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-22-2018, 06:54 AM
  2. [SOLVED] Values Based on Cell Options
    By GoGoeGo in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 07-20-2017, 11:55 AM
  3. Replies: 3
    Last Post: 05-11-2017, 10:24 PM
  4. [SOLVED] ListBox - Copy all selected options into a single cell seperated by commas
    By AusTempest in forum Excel Programming / VBA / Macros
    Replies: 19
    Last Post: 03-31-2014, 08:04 AM
  5. Based on listbox values, go to a URL in webbrowser containing those listbox values
    By krisspy in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 03-08-2014, 02:05 PM
  6. [SOLVED] VBA code to populate checkbox with tick upon initialization based on Cell value being Yes
    By michelle 1 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-05-2013, 09:58 AM
  7. Replies: 0
    Last Post: 02-21-2013, 02:06 PM

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