+ Reply to Thread
Results 1 to 7 of 7

“variable not defined” WITH FILTERED COMBOBOX/ LISTBOX COMBINATION

  1. #1
    Forum Contributor
    Join Date
    08-04-2018
    Location
    San Dieg CA
    MS-Off Ver
    Microsoft Office Professional Plus 2016 (Excel 2016 MSO 32 bit)
    Posts
    167

    “variable not defined” WITH FILTERED COMBOBOX/ LISTBOX COMBINATION

    Greeting All,
    I’m having some trouble with the below code. I’m trying to filter a my listbox with a combobox but continue to receive a “variable not defined” error. Any assistance is greatly appreciated. File also attached and as always thank you everyone!!!
    v/

    Please Login or Register  to view this content.
    Attached Files Attached Files

  2. #2
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,304

    Re: “variable not defined” WITH FILTERED COMBOBOX/ LISTBOX COMBINATION

    Initial problem cause - you refer in your code to sheet2 - you have renamed its code name in properties to SH2
    Also some of your cell referencing does not align with your form controls (i.e. textboxes etc.)
    if you are filtering your listbox using a combobox you will need a means of keeping note of actual row position if you are then going to edit retrieved data.

  3. #3
    Forum Contributor
    Join Date
    08-04-2018
    Location
    San Dieg CA
    MS-Off Ver
    Microsoft Office Professional Plus 2016 (Excel 2016 MSO 32 bit)
    Posts
    167

    Re: “variable not defined” WITH FILTERED COMBOBOX/ LISTBOX COMBINATION

    Torachan,

    you are absolutely correct. it's sloppy coding from long hours of mixing and matching code, desperately trying to get it to work. I've cleaned it up a bit, but now when I select a item from the dropdown combobox, my entire listbox disappears rather than produce a result. can I trouble you for some further assistance. thank you again.


    Please Login or Register  to view this content.

  4. #4
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,910

    Re: “variable not defined” WITH FILTERED COMBOBOX/ LISTBOX COMBINATION

    Remove this line:

    Quote Originally Posted by RoroBear View Post
    Dim Sheet2 As Range

  5. #5
    Forum Contributor
    Join Date
    08-04-2018
    Location
    San Dieg CA
    MS-Off Ver
    Microsoft Office Professional Plus 2016 (Excel 2016 MSO 32 bit)
    Posts
    167

    Re: “variable not defined” WITH FILTERED COMBOBOX/ LISTBOX COMBINATION

    Phuocam,

    So close! removing "Dim Sheet2 As Range" worked, but there is one small problem. it's not producing complete results. for example, there are 4 people in team DELTA, but when I select DELTA only 3 results show up. thank you for the speedy reply by the way.

    roro

  6. #6
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,910

    Re: “variable not defined” WITH FILTERED COMBOBOX/ LISTBOX COMBINATION

    Change:

    For i = 5 To Application.WorksheetFunction.CountA(Sheet2.Range("E:E"))

    to:

    For i = 2 To Application.WorksheetFunction.CountA(Sheet2.Range("E:E"))

  7. #7
    Forum Contributor
    Join Date
    08-04-2018
    Location
    San Dieg CA
    MS-Off Ver
    Microsoft Office Professional Plus 2016 (Excel 2016 MSO 32 bit)
    Posts
    167

    Re: “variable not defined” WITH FILTERED COMBOBOX/ LISTBOX COMBINATION

    Phuocam,

    it worked brilliantly! idk what i'd do without this forum. thank you everyone!

    v

+ 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. ListBox entries filtered by ComboBox selections
    By AndyE in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-11-2018, 08:31 PM
  2. [SOLVED] ComboBox to populate Listbox and 2nd Combobox based on 1st combobox dropdown choice
    By bbqqsmokeman in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-15-2017, 08:21 PM
  3. Replies: 16
    Last Post: 04-23-2015, 06:41 AM
  4. Combobox filtered with textbox; Listview filtered by combobox
    By Arvin.Amaro in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-02-2015, 11:48 AM
  5. Listbox.listcount property - application defined or object defined error
    By JulyMoon in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-02-2015, 04:30 PM
  6. In UserForm, how to populate a ComboBox/ListBox with a Range, defined by....
    By johnw993 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-07-2012, 11:06 PM
  7. ComboBox-programming / Compile Error: Variable not defined
    By katharil in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-30-2012, 07:40 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