+ Reply to Thread
Results 1 to 8 of 8

VBA delete entire row if value not found in Listbox

  1. #1
    Registered User
    Join Date
    03-31-2020
    Location
    Germany
    MS-Off Ver
    2010
    Posts
    7

    VBA delete entire row if value not found in Listbox

    Hello experts,

    I wrote a code that needs to compare values in range to Listbox items , and if not found in listbox (cause it was moved to Listbox2) then delete the row from range.
    Would appreciate any help! Thank you

    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: VBA delete entire row if value not found in Listbox

    Your code seems nice, what is the issue ?
    - Battle without fear gives no glory - Just try

  3. #3
    Registered User
    Join Date
    03-31-2020
    Location
    Germany
    MS-Off Ver
    2010
    Posts
    7

    Re: VBA delete entire row if value not found in Listbox

    The issue is that it doesnt work. )
    it doesnt delete the row which cells vaue is missing in listbox. And i dont understand why...
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: VBA delete entire row if value not found in Listbox

    I launched the form and selected MOL2 and MOL1 and was displayed A,B,C etc.. in the 2 windows and it deleted rows ...!

  5. #5
    Registered User
    Join Date
    03-31-2020
    Location
    Germany
    MS-Off Ver
    2010
    Posts
    7

    Re: VBA delete entire row if value not found in Listbox

    My point is, when i remove item from Listbox1 to listbox2, (e.g. "A"), i want only this row to be deleted from range when i click ok. THis is not working.
    it deletes all rows which are found in listbox1.

  6. #6
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: VBA delete entire row if value not found in Listbox

    The code in the OP is testing every cell in the range against only one item in the ListBox (the selected item)

    If you want to test against every item in the ListBox.
    Please Login or Register  to view this content.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  7. #7
    Registered User
    Join Date
    03-31-2020
    Location
    Germany
    MS-Off Ver
    2010
    Posts
    7

    Re: VBA delete entire row if value not found in Listbox

    Thank you!

  8. #8
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: VBA delete entire row if value not found in Listbox

    A bit late but here an update
    2 mistakes:
    1 - As Mike mentioned it you do not review Listbox values
    2 - The range in column "B" is not correct
    Please Login or Register  to view this content.

+ 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. Delete only selection instead of entire row if value found with VBA
    By ddasilva in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-18-2019, 04:58 PM
  2. [SOLVED] Loop through Column & delete entire row if Value is found
    By lougs7 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-01-2018, 02:56 PM
  3. Found?, then delete entire rows. Not found end sub
    By Andrewstupendo in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-21-2018, 01:56 PM
  4. [SOLVED] delete entire row when value is found
    By 9599lorenzo in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-14-2015, 03:06 AM
  5. [SOLVED] delete entire row when value is found
    By 9599lorenzo in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-13-2015, 06:47 PM
  6. Replies: 3
    Last Post: 10-05-2014, 11:48 AM
  7. [SOLVED] Delete Entire Row if Blank is Found in Column
    By EnigmaMatter in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 09-17-2014, 11:28 PM

Tags for this Thread

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