+ Reply to Thread
Results 1 to 6 of 6

Detecting Change of List Box

  1. #1
    Registered User
    Join Date
    09-14-2018
    Location
    Texas
    MS-Off Ver
    2013
    Posts
    4

    Red face Detecting Change of List Box

    Hi All,

    I have a workbook with several worksheets. I have this one worksheet that has charts and a list box on it. I can get the data to change in the charts after I click the refresh button. I would like to write some VBA code so the charts change after the user changes the items in the list box. I've tried the following code, but it doesn't work. Nothing happens. I've never worked with a Private Sub before. Maybe I'm doing something work or leaving something out.


    Private Sub Worksheet_Change(ByVal Target As Range)
    Worksheets("Sheet1").PivotTables("PivotTable1").PivotCache.Refresh
    End Sub

  2. #2
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5,883

    Re: Detecting Change of List Box

    What you want is to trap change in ListBox, not worksheet.

    What type of Listbox do you have on the sheet?

    Is it Form Control listbox or ActiveX listbox?
    ?Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something.?
    ― Robert A. Heinlein

  3. #3
    Registered User
    Join Date
    09-14-2018
    Location
    Texas
    MS-Off Ver
    2013
    Posts
    4

    Re: Detecting Change of List Box

    CK76,

    Thanks for the reply. I figured I needed to capture the change in the list box, but haven't figured it out yet. I do not think I have either. I created the list box by going to the Data Validation tab.

    Calvin

  4. #4
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5,883

    Re: Detecting Change of List Box

    Ah ok then. For data validation list, Worksheet_Change is correct event.

    Assuming Data validation is in separate sheet (sheet2) from PivotTable (sheet1).

    In Sheet2 module. Data validation in Cell B2
    0.JPG
    Please Login or Register  to view this content.
    If it is in the same sheet. Replace Worksheets("Sheet1") with Me. And put the code in the sheet module where PivotTable is located.

  5. #5
    Registered User
    Join Date
    09-14-2018
    Location
    Texas
    MS-Off Ver
    2013
    Posts
    4

    Red face Re: Detecting Change of List Box

    CK76,

    Thanks. I'll try that and let you know the results. Have a GREAT weekend.

    Calvin

  6. #6
    Registered User
    Join Date
    09-14-2018
    Location
    Texas
    MS-Off Ver
    2013
    Posts
    4

    Re: Detecting Change of List Box

    CK76,

    Thanks! That worked like a charm!!

    Calvin

+ 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] Detecting duplicate cells using info from the list
    By JackBauer in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 02-05-2014, 06:43 AM
  2. Replies: 5
    Last Post: 02-01-2013, 12:58 PM
  3. Replies: 2
    Last Post: 02-20-2012, 06:06 PM
  4. detecting change
    By etb1964 in forum Excel General
    Replies: 11
    Last Post: 01-19-2011, 05:40 AM
  5. Detecting change in a textbox
    By madhg in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-17-2009, 03:43 PM
  6. Problem detecting Excel 2003 file change.
    By bashara in forum Excel General
    Replies: 1
    Last Post: 04-11-2008, 04:05 AM
  7. Cell value - detecting change
    By tgmjf in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-20-2006, 03:12 PM
  8. Detecting worksheet change from modeless userform
    By Kent in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-27-2006, 03:25 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