Hi, Good morning,
So basically everything is in the title! I have a userform with a ListBox and I'm trying to refer to each particular item in the Listbox for a range but it doesn't work.
![]()
Please Login or Register to view this content.
Hi, Good morning,
So basically everything is in the title! I have a userform with a ListBox and I'm trying to refer to each particular item in the Listbox for a range but it doesn't work.
![]()
Please Login or Register to view this content.
Last edited by SIMBAtheCAT; 07-18-2014 at 12:45 PM.
Check the indentation of your code and it should be clear why it's not compiling.![]()
Please Login or Register to view this content.
You have a FOR NEXT loop arounf only the IF part of your IF THEN ELSE construct.
Tried it but it is just deleting every row.
I made this little code and it works. However, it's not as efficient as your code would be Andy Pope if it would be working.
![]()
Please Login or Register to view this content.
My bad. You actually want to delete if match rather than if not.
![]()
Please Login or Register to view this content.
No, you were right. I'm trying to keep the rows with the value in ListBox2 and hide the other rows.
Your code seems to just delete every single rows so I made so minor modifications without success. It still hides/deletes every rows :
![]()
Please Login or Register to view this content.
Hide or delete, there is a difference.
Your original code would suggest delete.
Can you post workbook example and detail what choices to make so we can see exactly what is happening.
Sure! Here is an image of my userform with the listbox :
Sans titre.PNG
The red circle is the objects I want to KEEP! Those objects.text can be found in another workbook always in the first column. When the objects are not in the ListBox2 then I want to HIDE the entire row.
Here is my code, it works BUT it takes literally 10 minutes to execute... :
![]()
Please Login or Register to view this content.
Last edited by SIMBAtheCAT; 07-16-2014 at 09:45 AM.
Yeah, not really a lot I can do with a redacted image.
I'm sorry but that is the maximum I can post here... Still I appreciate the will to help.
Instead of starting another thread,
I'm trying to rename the sheets of another workbook if they don't match the objects/items in a ListBox. However, I always get 'execution error 438.
![]()
Please Login or Register to view this content.
If that code is in the userform code module then you don't need the wbthis reference. You can use the Me object instead.
![]()
Please Login or Register to view this content.
No it's not in the userform code. It is in a macro and serves a error handlerpurpose :
![]()
Please Login or Register to view this content.
Have you not declared a object reference to you userform?
if not, and the userform is still in memory, you could resort to using userforms collection.
Although I think you would need to determine what index value to use![]()
Please Login or Register to view this content.
You are right. I just referred it manually without any loop. I'll dig more into that when I have some time off.
Could you help me make this code more efficient because when I run it, it just stays in execute mode forever (literally)...
![]()
Please Login or Register to view this content.
Back to issue of needing example workbook
Once again, I can't provide that. However, after a couple of changes, I made it work :
![]()
Please Login or Register to view this content.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks